Compiling kernel with -std=gnu11

Taylor R Campbell <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Currently we compile the kernel with -std=gnu99.  Someone recently
added some code that uses the u"foo" syntax for UTF-16 literals, which
is new in C11.  With -std=gnu99, gcc accepts this syntax but clang
rejects it -- clang requires -std=c11 or -std=gnu11.

We could switch to L"foo" like is being used elsewhere, but it's not
exactly correct -- the data in question really are fixed to be UTF-16,
not some arbitrary interpretation of wide characters.  We may also
want to use other C11 features such as _Atomic in the future.

Any objections to compiling the kernel with -std=gnu11 instead?
kern-gnu11.patch (text/plain, 456 B)
diff -r 876c5a9056ed sys/conf/Makefile.kern.inc
--- a/sys/conf/Makefile.kern.inc	Sun Jan 05 14:27:10 2025 +0000
+++ b/sys/conf/Makefile.kern.inc	Sun Jan 05 14:48:17 2025 +0000
@@ -66,7 +66,7 @@ INCLUDES?=	-I. ${EXTRA_INCLUDES} -I${S}/
 		-I$S -nostdinc
 CPPFLAGS+=	${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
 .if !defined(COVERITY_TOP_CONFIG)
-CPPFLAGS+=	-std=gnu99
+CPPFLAGS+=	-std=gnu11
 .endif
 .if ${KERNEL_DIR:Uno} == "yes"
 CPPFLAGS+=	-DKERNEL_DIR
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.