Type attributes (IBM extension)

Type attributes are language extensions provided to facilitate compilation of programs developed with the GNU C compiler compilers. These language features allow you to use named attributes to specify special properties of data objects. Any variables that are declared as having that type will have the attribute applied to them.

A type attribute is specified with the keyword __attribute__ followed by the attribute name and any additional arguments the attribute name requires. Although there are variations, the syntax of a type attribute is of the general form:

Read syntax diagramSkip visual syntax diagram
Type attribute syntax

>>-type_name--__attribute__------------------------------------->

       .-,----------------------.                           
       V                        |                           
>--((----+-attribute name-----+-+--))--+----------------+------->
         '-__attribute name__-'        '-tag_identifier-'   

>--{--member_definition_list--}--;-----------------------------><

Read syntax diagramSkip visual syntax diagram
Type attribute syntax — typedef declarations

>>-typedef--type_declaration--type_name------------------------->

                      .-,----------------------.          
                      V                        |          
>--__attribute__--((----+-attribute name-----+-+--))--;--------><
                        '-__attribute name__-'            

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. For unsupported attribute names, the XL C compiler issues diagnostics and ignores the attribute specification. Multiple attribute names can be specified in the same attribute specification.