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?



On Dec 4, 2026, at 11:52 AM, Thor Lancelot Simon <tls%panix.com@localhost> wrote:

> I thought I'd understood you to have said that the use of the language feature, in C,
> on Apple's part, was driven by users who had actually experienced ABI incompatibilty
> by compiling their own code with -fshort-enum.  If Apple didn't actually have enums
> in binary interfaces exposed to others' code _prior_ to the introduction of this
> language feature in C, I can't see how this would have been possible.
> 
> But clearly I am missing some part of the picture.
> 

I think that’s on me for trying to explain several different things at once; there were multiple concerns involved in extending the C++ language feature to ObjC and C (and then promoting it to the standards body to get into C23).

Back when NeXT & Apple used anonymous enums and int typedefs, compatibility of system API & ABI with ported code that needed to use e.g. -fshort-enum wasn’t a problem, because enum sizes only actually mattered to the ported code[1].

So when the desire to use “real” enum types in API came to the forefront (for the developer ergonomics reasons I’ve cited), keeping things like -fshort-enum working was also an important aspect of any solution.

  — Chris

[1] Think “Code that depends on exact structure layout to read & write asset files, is too large or spread too wide across a codebase to rewrite, and will be a headache to update to a newer code drop if too many invasive changes are made.” I saw that sort of thing in porting games from DOS & Windows to the Mac back in the day: Game code often played *very* fast and loose with the language, treating it more as “whatever the compiler and OS will happen to let us get away with.”


Home | Main Index | Thread Index | Old Index