Use C11 as baseline for C source code in the JDK

Magnus Ihse Bursie magnus.ihse.bursie at oracle.com
Mon Aug 8 13:54:24 UTC 2022


In JDK-8292008 [1], it is proposed to set C11 as the common minimum 
language level/standard for all native C files in the JDK.

Since some time ago, we have C++14 as the standard for all C++ files. 
For C files, the situation has been a bit messier. gcc and clang has 
used C99, but the Microsoft Visual Studio compiler never officially 
supported C99, so we just use the default there, which is a bit of a 
hodge-podge of partial C99 support, and partial C11 support.

Starting with Visual Studio 2019, full C11 support is provided even for 
this toolchain.

A simple test which just sets the C11 requirement compiler flags shows 
no issues building on any of our platforms. (Or close to no: It triggers 
a preprocessor warning on Windows, but it's trivial to deal with.)

I propose we go ahead with this change, and raise the minimum C language 
level to C11, and also get it consistent across all platforms.

This will require us to retire support for Visual Studio 2017, or 
alternatively, assume that the partial C11 support that VS2017 has, is 
enough, and keep it as an "at your own risk" alternative for the time being.

A change like this will furthermore require approximately the same kind 
of testing as a compiler upgrade.

Thoughts?

/Magnus

[1] https://bugs.openjdk.org/browse/JDK-8292008



More information about the jdk-dev mailing list