8

I am used to using -std=c99 to enable c99 features when compiling application code.

Recently I have been following some basic kernel module examples, and added ccflags-y := -std=c99 to the makefile. However this resulted in 17K lines of errors when I tried to make. gnu99 works perfectly.

What is the difference between gnu99 and c99 that kernel code relies on?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
jsj
  • 9,019
  • 17
  • 58
  • 103
  • 1
    +1. And you're not the first to notice. See http://llvm.linuxfoundation.org/ – 0xC0000022L May 17 '14 at 03:46
  • Basically, the kernel uses GCC extensions and does not compile when they are turned off. – Jonathan Leffler May 17 '14 at 03:52
  • `What is the difference between gnu99 and c99 that kernel code relies on?`. I think you can find these differences yourself. This is from gcc doc: `GNU C provides several language features not found in ISO standard C. (The -pedantic option directs GCC to print a warning message if any of these features is used.) `. So, build the kernel with `gnu99` but add `ccflags-y := -pedantic`. And then analyze warnings. This is from gcc's doc: https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/C-Extensions.html#C-Extensions –  May 17 '14 at 06:11

1 Answers1

1

The linux kernel uses a lot of GCC extensions i.e., the C language used in the kernel is not standards compliant, it is a superset which includes GCC extension. Hence GNU99 is the compiler option which needs to be passed.

pranith
  • 869
  • 9
  • 24
  • 1
    Actually, the Linux kernel itself is built using gnu89, not gnu99, because of semantic differences (such as the one discussed here: [http://www.kernelhub.org/?p=2&msg=606456](http://www.kernelhub.org/?p=2&msg=606456)). Hence, gnu89 should probably also be preferred as standard when making kernel modules, since included kernel-mode headers will likely rely on this standard. – Erlend Graff Jan 24 '15 at 18:23