Next:Label Attributes, Previous:Specifying Attributes of Variables, Up:Attributes Specific to GCC [Contents][Index]
You can use attributes to specify various specialproperties of types. Some type attributes apply only to structure andunion types, and in C++, also class types, while others can apply toany type defined via atypedef declaration. Unless otherwisespecified, the same restrictions and effects apply to attributes regardlessof whether a type is a trivial structure or a C++ class with user-definedconstructors, destructors, or a copy assignment.
Other attributes are defined for functions (seeDeclaring Attributes of Functions),labels (seeLabel Attributes), enumerators (seeEnumerator Attributes), statements (seeStatement Attributes), and for variables(seeSpecifying Attributes of Variables).
GCC provides two different ways to specify attributes: the traditionalGNU syntax using ‘__attribute__ ((...))’ annotations, and thenewer standard C and C++ syntax using ‘[[...]]’ with the‘gnu::’ prefix on attribute names. Note that the exact rules forplacement of attributes in your source code are different depending onwhich syntax you use. SeeAttribute Syntax, for details.
You may specify type attributes in an enum, struct or union typedeclaration or definition by placing them immediately after thestruct,union orenum keyword. You can also placethem just past the closing curly brace of the definition, but this is lesspreferred because logically the type should be fully defined at the closing brace. You can also include type attributes in atypedef declaration.
Next:Label Attributes, Previous:Specifying Attributes of Variables, Up:Attributes Specific to GCC [Contents][Index]