[jdk11u-dev] RFR: 8224087: Compile C code for at least C99 Standard compliance
Andrew John Hughes
andrew at openjdk.org
Sun Sep 7 15:10:23 UTC 2025
On Wed, 3 Sep 2025 11:23:31 GMT, Zdenek Zambersky <zzambers at openjdk.org> wrote:
> This backport explicitly sets c99 standard for jdk c sources on compilers, where appropriate. Motivation for this is, [recent gcc switch to c23 as default](https://www.phoronix.com/news/GCC-15-Default-C23), causing errors (jdk sources are not c23 compatible).
>
> Main problem is, that c23 no longer supports non-prototype function declarations (see (3) [here](https://en.cppreference.com/w/c/language/function_declaration.html)). Example errors:
>
> /mnt/ramdisk/java-11-openjdk-11.0.28.0.6-1.portable.jdk.el.x86_64.tarxz/src/src/java.base/unix/native/libnet/DefaultProxySelector.c:389:16: error: too many arguments to function 'g_proxy_resolver_lookup'; expected 0, have 4
> 389 | proxies = (*g_proxy_resolver_lookup)(resolver, uri, NULL, &error);
> | ~^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
>
>
>
> /mnt/ramdisk/java-11-openjdk-11.0.28.0.6-1.portable.jdk.el.x86_64.tarxz/src/test/hotspot/jtreg/runtime/jsig/libTestJNI.c:45:22: error: assignment to 'void (*)(int, siginfo_t *, void *)' from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
> 45 | act.sa_sigaction = (void (*)())sig_handler;
> | ^
>
>
> There are more, if above are fixed. Non prototype function declarations are present even in newest jdk, but newer jdks have c standard set explicitly, so they do not cause errors there.
>
> This should not increase minimum requirements for compiler toolchains needed to build jdk11. [Jdk13](https://github.com/openjdk/jdk13/blob/master/doc/building.md#native-compiler-toolchain-requirements), where this originates from, has same minimal compiler requirements as [jdk11](https://github.com/zzambers/jdk11u-dev/blob/master/doc/building.md#native-compiler-toolchain-requirements). ( gcc 4.8, clang 3.2, Xcode 8, Solaris Studio 12.4)
I'm in two minds about this. Specifying the standard explicitly is the right thing to do (I added similar for C++ years back) but we could just make that C90 so as to not raise older compilers.
I think, given some compilers have been defaulting to C99 for some time anyway (and maybe even later), this should be safe and may avoid problems with future backports. Let's get it in early and ensure it is well tested before January.
What compilers have you tested this change with?
-------------
Changes requested by andrew (Reviewer).
PR Review: https://git.openjdk.org/jdk11u-dev/pull/3087#pullrequestreview-3194484222
More information about the jdk-updates-dev
mailing list