Function attributes (IBM extension)
Function attributes are extensions implemented to enhance the portability of programs developed with GNU C. Specifiable attributes for functions provide explicit ways to help the compiler optimize function calls and to instruct it to check more aspects of the code. Others provide additional functionality.
IBM® XL C compiler implements a subset of the GNU C function attributes. For a particular function attribute that is not implemented, the compiler issues diagnostics and ignores the attribute specification.
A function attribute is specified with the keyword __attribute__ followed by the attribute name and any additional arguments the attribute name requires. A function __attribute__ specification is included in the declaration or definition of a function. The syntax takes the following forms:
Function attribute syntax: function definition (form 1) >>-return_type--__attribute__-----------------------------------> .-,--------------------------. V | >--((----+-attribute name---------+-+--))-----------------------> '-__--attribute_name--__-' >--function_declarator-----------------------------------------><
You can specify attribute_name with or without leading and trailing double underscore characters; however, using the double underscore characters reduces the likelihood of name conflicts with macros of the same name. These language features are collectively available when compiling in any of the extended language levels.
int __attribute__((attribute_name)) func(int i); //Form 1
__attribute__((attribute_name)) int func(int); //Form 2
int func() __attribute__((attribute_name)); //Form 3
The following function attributes are supported: