Which C version is used in the Linux kernel?

后端 未结 3 1257
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 04:06

Does the Linux kernel use only the old C90 syntax or has it been optimized with C99 / C11 features?

I was wondering if the newest versions of C are used when possible

3条回答
  •  心在旅途
    2020-12-13 04:37

    There isn't really an answer because your question makes faulty assumptions. The C language versions assume the existence of a platform, but OS kernels like Linux are the platform (or at least a large part of it), so they don't have a "version" in that sense.

    In terms of the parser's definition of the language, Linux is written in whatever a the concurrent gcc/icc/etc. will support, which as of now is C99. But like I said, the differences between C90 and C99 are based on the kernel and the library so they don't really apply to the kernel to begin with. (The only exception I can think of is anonymous functions, which the kernel doesn't use.)

    Most of the day-to-day things you know about C are actually from the library, which depends on the kernel. So when you're programming a kernel, you're actually dealing with a much different set-up than when you are writing a normal C program.

提交回复
热议问题