gcc: Function Attributes

1 
1 6.31 Declaring Attributes of Functions
1 ======================================
1 
1 In GNU C, you can use function attributes to declare certain things
1 about functions called in your program which help the compiler optimize
1 calls and check your code more carefully.  For example, you can use
1 attributes to declare that a function never returns ('noreturn'),
1 returns a value depending only on its arguments ('pure'), or has
1 'printf'-style arguments ('format').
1 
1  You can also use attributes to control memory placement, code
1 generation options or call/return conventions within the function being
1 annotated.  Many of these attributes are target-specific.  For example,
1 many targets support attributes for defining interrupt handler
1 functions, which typically must follow special register usage and return
1 conventions.
1 
1  Function attributes are introduced by the '__attribute__' keyword on a
1 declaration, followed by an attribute specification inside double
1 parentheses.  You can specify multiple attributes in a declaration by
1 separating them by commas within the double parentheses or by
1 immediately following an attribute declaration with another attribute
1 declaration.  ⇒Attribute Syntax, for the exact rules on attribute
1 syntax and placement.  Compatible attribute specifications on distinct
1 declarations of the same function are merged.  An attribute
1 specification that is not compatible with attributes already applied to
1 a declaration of the same function is ignored with a warning.
1 
DONTPRINTYET 11  GCC also supports attributes on variable declarations (⇒Variable
 Attributes), labels (⇒Label Attributes), enumerators (*note1DONTPRINTYET 11  GCC also supports attributes on variable declarations (⇒Variable
 Attributes), labels (⇒Label Attributes), enumerators (⇒
 Enumerator Attributes), statements (⇒Statement Attributes), and
1 types (⇒Type Attributes).
1 
1  There is some overlap between the purposes of attributes and pragmas
1 (⇒Pragmas Accepted by GCC Pragmas.).  It has been found convenient
1 to use '__attribute__' to achieve a natural attachment of attributes to
1 their corresponding declarations, whereas '#pragma' is of use for
1 compatibility with other compilers or constructs that do not naturally
1 form part of the grammar.
1 
1  In addition to the attributes documented here, GCC plugins may provide
1 their own attributes.
1 

Menu