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 3, 2026, at 3:48 PM, Bobby Bingham <koorogi%koorogi.info@localhost> wrote:
> 
> On Thu, 3 Dec 2026 13:54:20 -0800
> Chris Hanson <cmhanson%eschatologist.net@localhost> wrote:
> 
>> The problem is that without attaching a specific type, the language
>> allows the compiler to choose the type to use to represent the
>> enumeration, which means it can change based on things like compiler
>> options, which in turn means the use of enum for defining types is
>> not ABI-stable.
> 
> There are many compiler options that can change the ABI in incompatible
> ways, ranging from completely incompatible (e.g., -m32/-m64) to more
> subtle differences (-m[no-]align-double, -mlong-double-*,
> -mpreferred-stack-boundary, -msoft-float on some targets, etc).
> 
> I don't think the solution is to try to code around these options, but
> to say they shouldn't be used where ABI compatibility matters.

The language committees obviously disagree, as the specific language feature I’m talking about was added to C++ and then Objective-C and finally to C specifically so language users would no longer have to worry about this ABI risk.

More specifically, I’d say that using anonymous enums and int in APIs is coding around a flaw in C’s specification of enum, and that the explicit typing feature eliminates the need to code around this flaw.

  — Chris



Home | Main Index | Thread Index | Old Index