GNU Extensions

GNU Extensions are explicitly allowed in the Linux kernel. Note that some of the more complex ones are not very well supported, due to lack of general use, but the following are considered standard (see the GCC info page section "C Extensions" for more details - Yes, really the info page, the man page is only a short summary of the stuff in info):

  • Inline functions

  • Statement expressions (ie. the ({ and }) constructs).

  • Declaring attributes of a function / variable / type (__attribute__)

  • Labeled elements

  • typeof

  • Zero length arrays

  • Macro varargs

  • Arithmetic on void pointers

  • Non-Constant initializers

  • Assembler Instructions (not outside arch/ and include/asm/)

  • Function names as strings (__FUNCTION__)

  • __builtin_constant_p()

Be wary when using long long in the kernel, the code gcc generates for it is horrible and worse: division and multiplication does not work on i386 because the GCC runtime functions for it are missing from the kernel environment.