Variable Attributes

Linux Variable attributes are orthogonal language extensions provided to facilitate handling programs developed with the GNU C/C++ compilers. These language features allow you use named attributes to modify the declarations of variables. The syntax and supported variable attributes are described in this section. For unsupported attribute names, the IBM C/C++ compilers issue diagnostics and ignore the attribute specification.

The keyword __attribute__ specifies a variable attribute. An attribute syntax has the general form:

                      .-,----------------------.
                      V                        |
>>-__attribute__--((----+--------------------+-+--))-----------><
                        +-attribute_name-----+
                        '-__attribute_name__-'
 
 

Attribute specifiers are declaration specifiers, and therefore can appear before the declarator in a declaration. The attribute specifier can also follow a declarator. In this case, it applies only to that particular declarator in a comma-separated list of declarators.

A variable attribute specification using the form __attribute_name__ (that is, the variable attribute keyword with double underscore characters leading and trailing) reduces the likelihood of a name conflict with a macro of the same name.

Related References

IBM Copyright 2003