<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >GNU Extensions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Unreliable Guide To Hacking The Linux Kernel" HREF="book1.html"><LINK REL="UP" TITLE="Routines and Conventions" HREF="c412.html"><LINK REL="PREVIOUS" TITLE="Initializing structure members" HREF="x432.html"><LINK REL="NEXT" TITLE="C++" HREF="x466.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Unreliable Guide To Hacking The Linux Kernel</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x432.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Routines and Conventions</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x466.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="CONVENTIONS-GNU-EXTNS" ></A >GNU Extensions</H1 ><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 ><P ></P ><UL ><LI ><P > Inline functions </P ></LI ><LI ><P > Statement expressions (ie. the ({ and }) constructs). </P ></LI ><LI ><P > Declaring attributes of a function / variable / type (__attribute__) </P ></LI ><LI ><P > Labeled elements </P ></LI ><LI ><P > typeof </P ></LI ><LI ><P > Zero length arrays </P ></LI ><LI ><P > Macro varargs </P ></LI ><LI ><P > Arithmetic on void pointers </P ></LI ><LI ><P > Non-Constant initializers </P ></LI ><LI ><P > Assembler Instructions (not outside arch/ and include/asm/) </P ></LI ><LI ><P > Function names as strings (__FUNCTION__) </P ></LI ><LI ><P > __builtin_constant_p() </P ></LI ></UL ><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 ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x432.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x466.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Initializing structure members</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c412.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >C++</TD ></TR ></TABLE ></DIV ></BODY ></HTML >