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?
> Date: Thu, 03 Dec 2026 20:30:57 -0500
> From: Greg Troxel <gdt%lexort.com@localhost>
>
> Chris Hanson <cmhanson%eschatologist.net@localhost> writes:
>
> > It sounds like this is the approach I should take in what I'm
> > hacking on in order to enable compilation in older language modes.
>
> I think what's appropriate is for you to propose specific changes to
> the existing rules to core@ and then follow what core@ decides.
Is this for code in NetBSD, or code that runs on NetBSD? I wasn't
clear from the original question.
It also makes a difference whether we're talking about public header
files or other code. Public header files in NetBSD, with public APIs,
should generally work in C _or_ C++, in any revision of the standard
(although there are some unavoidable compiler-specific extensions like
in sys/cdefs.h).
We should perhaps add some atf tests for this: for each header file we
distribute, compile a trivial .c file that includes it using each
revision of the standard, and likewise for C++. I expect there has
been some C89 bitrot, and maybe C89 doesn't matter any more.
> /usr/share/misc/style doesn't specifically allow or prohibit writing in
> any particular C sublanguage. That's either a bug, or just that it's in
> /usr/share/mk/bsd.sys.mk.
>
> bsd.sys.mk says:
>
> # NetBSD sources use C99 style, with some GCC extensions.
> # Coverity does not like -std=gnu99 (XXX untested but likely not gnu11 either)
> #
> # XXX Ideally we would not rely on GNU extensions, but currently some
> # code uses alloca(3) which -std=c11 compiles broken-at-runtime. Until
> # we fix that (PR toolchain/58969: use of alloca is warning, not error,
> # with -std=c11), we have to continue using -std=gnu11 and not
> # -std=c11.
>
> That should probably be checked and clarified, as there's no explanation
> of why after saying C99 it's gnu11/c11 being discussed. Overall I read
> it as "sources should be C99, and it's a bug to need C11 or gnu
> extensions, but that's where we are", but I'm not at all sure I'm
> getting it right.
The discussion prompting the change from -std=gnu99 to -std=gnu11 was
here:
https://mail-index.netbsd.org/tech-kern/2025/01/05/msg029919.html
With some followon discussion about -std=gnu11 vs -std=c11 and why
switching to the latter is a bad idea:
PR toolchain/58969: use of alloca is warning, not error, with -std=c11
https://gnats.netbsd.org/58969
C11 has been mostly uncontroversial, in contrast to C23, so it wasn't
a big discussion.
Home |
Main Index |
Thread Index |
Old Index