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?
Chris Hanson <cmhanson%eschatologist.net@localhost> writes:
>> 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.
Compiler authors are aggressive in general :-( I wasn't really worried
so much about building the NetBSD sources.
> 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).
It's not just about other compilers. In pkgsrc, we have run into quita
a few programs that fail to build with --std=c23 (almost always, an
implicit --std because of an aggressive default, when no --std was
passed). Such programs are usually from a simpler time when just
writing to C99 and not paying attention to passing --std was a fine
thing to do, and expected to work forever. It pretty much did until
C23.
We've add FORCE_CC_STD=c99 (or gnu99) to such programs, which has the
wrappers add the --std=c99, so the programs are treated as being written
in the language they are actually written in, not an
incompatible-even-if-mostly-compatible newer language.
I am unclear on what our rules are for headers, in terms of if c99 is
enough. I have not run into "program when set to c99 mode fails to
build because foo.h was included and that needs c11."
All in all, this feels like too much complexity imposed on everyone to
solve a perhaps-theoretical safety problem.
Home |
Main Index |
Thread Index |
Old Index