Article View: muc.lists.netbsd.tech.kern
Article #33Re: Do all -current compilers support C23 typed enum syntax?
From: Mouse
Date: Thu, 03 Dec 2026 13:12
Date: Thu, 03 Dec 2026 13:12
42 lines
2558 bytes
2558 bytes
> For example:
> typedef enum : int {
> subsys_thing_a = 0,
> subways_thing_b,
> } subsys_thing_t;
> int subsys_call(subsys_thing_t thing);
What benefit does this bring? enum constants have historically been
ints (I don't _like_ this - it feels to me like conceptual type
confusion - but it's how they've worked), so, unless you anticipate
wanting an argument that is smaller or larger than int, I see no value
in attaching a specific type to it. Even if you do, all you need is to
document the argument as having its actual type. The only real
difference I see between
enum {
FOO = 1,
BAR,
BAZ,
};
and
#define FOO 1
#define BAR 2
#define BAZ 3
is that they obey different scope rules. You can pass either one to an
argument of any integral type just fine (well, possibly except _Bool).
What am I missing?
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<202612031312.IAA24669@Stone.Rodents-Montreal.ORG>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailReferences:
<FDE08146-A944-4663-80AF-A6953560BF9D@eschatologist.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: Mouse <mouse@Rodents-Montreal.ORG> Newsgroups: muc.lists.netbsd.tech.kern Subject: Re: Do all -current compilers support C23 typed enum syntax? Date: Thu, 3 Dec 2026 08:12:13 -0500 (EST) Organization: Newsgate at muc.de e.V. Sender: tech-kern-owner@NetBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <202612031312.IAA24669@Stone.Rodents-Montreal.ORG> References: <FDE08146-A944-4663-80AF-A6953560BF9D@eschatologist.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="31425"; mail-complaints-to="news-admin@muc.de" X-Erik-Conspiracy: There is no Conspiracy - and if there were I wouldn't be part of it anyway. X-Message-Flag: Microsoft: the company who gave us the botnet zombies. X-Composition-Start-Date: Thu, 3 Dec 2026 07:57:30 -0500 (EST) In-Reply-To: <FDE08146-A944-4663-80AF-A6953560BF9D@eschatologist.net> Precedence: bulk X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes