<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>GNU Extensions</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel" /><link rel="up" href="ch10.html" title="Chapter 10. Routines and Conventions" /><link rel="prev" href="ch10s04.html" title="Initializing structure members" /><link rel="next" href="ch10s06.html" title="C++" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">GNU Extensions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch10s04.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Routines and Conventions</th><td width="20%" align="right"> <a accesskey="n" href="ch10s06.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="GNU Extensions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="conventions-gnu-extns"></a>GNU Extensions</h2></div></div></div><p> 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). </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> Inline functions </p></li><li class="listitem"><p> Statement expressions (ie. the ({ and }) constructs). </p></li><li class="listitem"><p> Declaring attributes of a function / variable / type (__attribute__) </p></li><li class="listitem"><p> typeof </p></li><li class="listitem"><p> Zero length arrays </p></li><li class="listitem"><p> Macro varargs </p></li><li class="listitem"><p> Arithmetic on void pointers </p></li><li class="listitem"><p> Non-Constant initializers </p></li><li class="listitem"><p> Assembler Instructions (not outside arch/ and include/asm/) </p></li><li class="listitem"><p> Function names as strings (__func__). </p></li><li class="listitem"><p> __builtin_constant_p() </p></li></ul></div><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. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch10s04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch10.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch10s06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Initializing structure members </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> C++</td></tr></table></div></body></html>