Re: Compiling kernel with -std=gnu11

Taylor R Campbell <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
> Date: Sun, 5 Jan 2025 16:19:50 +0100
> From: Anders Magnusson <[email protected]>
> 
> Den 2025-01-05 kl. 15:48, skrev Taylor R Campbell:
> > Any objections to compiling the kernel with -std=gnu11 instead?
> What are the reasons why we cannot use -std=c11 instead in that case?

Good question!  I just tried building aarch64 and i386 GENERIC kernels
with -std=c11 and the only issue that came up was the use of the
nonstandard keywords asm and typeof.  Compiling with -std=c11
-Dasm=__asm -Dtypeof=__typeof worked fine.

I skimmed through
https://gcc.gnu.org/onlinedocs/gcc-10.5.0/gcc/C-Extensions.html
for other things whose semantics might change with -std=gnu11 vs
-std=c11, and the only case I came up with was the `\e' escape in
strings, of which we have one use:

sys/fs/udf/udf_osta.c:238:	printf("checksum: calculated=%4.4x, correct=%4.4x\en", x, 0x3299);

This looks like it might be a mistake anyway.

So maybe we can get by with -std=c11 and some judiciously placed
#define asm __asm and similar without any effort beyond that.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.