Why the Linux Kernel Is Moving to C11 and What It Means
Arnd Bergmann's new patch lets the Linux kernel default to the GNU11 dialect, enabling modern C99/C11 features, with Linus Torvalds' backing, and the change is set to be tested in the upcoming v5.18 release.
Kernel developer Arnd Bergmann submitted a patch that makes the Linux kernel use -std=gnu11 by default when the C11 GNU dialect is selected, allowing the kernel to take advantage of many C99/C11 features instead of being limited to C89. Linus Torvalds supports the change, and if no fundamental problems appear it will continue in the next merge window.
During the patch discussion Linus suggested moving the C standard version from gnu89 to gnu99, which permits variable declarations inside for() loops. Although C99, C11 and later standards introduce many new features, most of them are already available in gnu89 as GNU extensions. Earlier gcc‑5 tried to default to -std=gnu1 but failed because it triggered warnings about old‑style initializers. Now gcc‑5.1 is the minimum compiler version for building the kernel, so this is no longer an issue. The behavior of inline functions differs between gnu89 and gnu11, but it has been resolved by defining inline with __attribute__((gnu_inline)) , allowing clang to build the kernel. A minor issue remains: when building with -Werror , a gcc warning about shifting negative integers appears (triggered by the make W=1 option). All three kernel drivers enable -Werror , but only the i915 driver currently shows this warning. To be safe, -Wno-shift-negative-value should be added to any -Wextra in the Makefile. Nathan Chancellor reported an additional -Wdeclaration-after-statement warning in an ARM system header, which still needs a workaround. The differences among gnu99, gnu11, gnu1x and gnu17 are small, mainly affecting the -Wpedantic warning level that the kernel never enables. Between these versions, gnu11 is the newest one supported by all compilers; gcc‑5 defaults to gnu1x/gnu17, while other supported gcc or clang versions also default to those standards.
The kernel community recently debated adopting a modern C language standard. Linus proposed moving from C89 to C99, noting that older gcc versions caused strange bugs that broke initialization code. With the minimum required gcc now at version 5.1, those bugs are largely irrelevant.
Given the current compiler requirements, the kernel can start being built with C11. Bergmann even suggested jumping directly to C11 or C2x. While he is unsure whether C11 brings useful new features for the kernel, moving to C17 or C2x would break support for gcc‑5/6/7, making C11 the more feasible upgrade. After confirming the feasibility, Linus announced that the next kernel version (v5.18) will experiment with the C11 standard.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
