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 4:20 AM, Greg Troxel <gdt%lexort.com@localhost> wrote:
> 
> Chris Hanson <cmhanson%eschatologist.net@localhost> writes:
> 
>> I’m designing a subsystem (including system calls) and I’d like to use “typed enums” in the API rather than #define or anonymous enums and int parameters.
> 
> Would this mean that programs that either
>  use your API
>  include a header where this is defined
> 
> could only be compiled with a compiler in --std=c23 mode?

This is a good point. Apparently -current (both the userspace and kernel) are compiled in --std=c23 mode, but I didn’t check whether that was explicitly passed or whether it was the compiler’s default. The C committee has been *much* better about backwards compatibility with existing code in new standards than, say, C++, so compilers can be much more aggressive about enabling newer C standards by default.

Nonetheless, this would affect people trying to use alternative compilers with NetBSD’s system headers, so even if I did go forward with using a typed enum in this API, I’d still probably need to use macros to fall back to pre-C23 declarations (like Apple’s APIs do).

  — Chris



Home | Main Index | Thread Index | Old Index