tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Do all -current compilers support C23 typed enum syntax?



Morning,

Den 2026-12-04 kl. 07:33, skrev Chris Hanson:
On Dec 3, 2026, at 9:24 PM, Thor Lancelot Simon <tls%panix.com@localhost> wrote:
On Thu, Dec 03, 2026 at 08:31:18PM -0800, Chris Hanson wrote:
In general, this is not a fruitful line of discussion: Compilers do exist to serve their users, but those users have many different and competing needs, and optimization for both speed and size are among them. And the language specification is ultimately what defines ???broken??? when it comes to how to best meet those needs.
I have been avoiding so far in this conversation noting that really, this
all stems from Apple buying itself a 50 gallon drum of trouble by just begging
for UB by using "enum" in ABI elements, but, this seems like the time to say
it.
You were right to avoid it, because I don’t think saying this advances the conversation at all. It presumes the people designing and implementing APIs and maintaining ABI compatibility at NeXT and Apple did not or do not know what they’re doing. To recount a little more history: NeXT and Apple *didn’t* originally use enum types directly in API precisely because of the problems they present for ABI stability in their C89 and C99 form. Instead, they followed the “anonymous enum plus typedef of int” model.
Hm, I get the feeling it is a slight confusion somewhere....?
How enum works is well defined in c99, and ABIs based on it would have no problem.

- C99 states that enum should have a type compatible with "int" (not "long int" or so; not integer type, just "int").
- Use of prototypes including enums must have the same enum declarations.
- Using no prototypes (uncommon these days) will force "default argument promotions".

The OS/target ABI declares how enums should be handled, so that would be a no-brainer.

Giving flags to compilers may of course break everything, like using register arguments on x86.  So if someone uses any flags other than the system default flags, he is on his own.

-- Ragge



Home | Main Index | Thread Index | Old Index