1
2
3
4
5
6
|
<div class="section-level-extent" id="Type-Attributes"> <div class="nav-panel"> <p> Next: <a href="label-attributes" accesskey="n" rel="next">Label Attributes</a>, Previous: <a href="variable-attributes" accesskey="p" rel="prev">Specifying Attributes of Variables</a>, Up: <a href="c-extensions" accesskey="u" rel="up">Extensions to the C Language Family</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Specifying-Attributes-of-Types"><span>6.35 Specifying Attributes of Types<a class="copiable-link" href="#Specifying-Attributes-of-Types"> ¶</a></span></h1> <p>The keyword <code class="code">__attribute__</code> allows you to specify various special properties of types. Some type attributes apply only to structure and union types, and in C++, also class types, while others can apply to any type defined via a <code class="code">typedef</code> declaration. Unless otherwise specified, the same restrictions and effects apply to attributes regardless of whether a type is a trivial structure or a C++ class with user-defined constructors, destructors, or a copy assignment. </p> <p>Other attributes are defined for functions (see <a class="pxref" href="function-attributes">Declaring Attributes of Functions</a>), labels (see <a class="pxref" href="label-attributes">Label Attributes</a>), enumerators (see <a class="pxref" href="enumerator-attributes">Enumerator Attributes</a>), statements (see <a class="pxref" href="statement-attributes">Statement Attributes</a>), and for variables (see <a class="pxref" href="variable-attributes">Specifying Attributes of Variables</a>). </p> <p>The <code class="code">__attribute__</code> keyword is followed by an attribute specification enclosed in double parentheses. </p> <p>You may specify type attributes in an enum, struct or union type declaration or definition by placing them immediately after the <code class="code">struct</code>, <code class="code">union</code> or <code class="code">enum</code> keyword. You can also place them just past the closing curly brace of the definition, but this is less preferred because logically the type should be fully defined at the closing brace. </p> <p>You can also include type attributes in a <code class="code">typedef</code> declaration. See <a class="xref" href="attribute-syntax">Attribute Syntax</a>, for details of the exact syntax for using attributes. </p> <ul class="mini-toc"> <li><a href="common-type-attributes" accesskey="1">Common Type Attributes</a></li> <li><a href="arc-type-attributes" accesskey="2">ARC Type Attributes</a></li> <li><a href="arm-type-attributes" accesskey="3">ARM Type Attributes</a></li> <li><a href="bpf-type-attributes" accesskey="4">BPF Type Attributes</a></li> <li><a href="type-attributes" accesskey="5">PowerPC Type Attributes</a></li> <li><a href="type-attributes" accesskey="6">x86 Type Attributes</a></li> </ul> </div> <div class="nav-panel"> <p> Next: <a href="label-attributes">Label Attributes</a>, Previous: <a href="variable-attributes">Specifying Attributes of Variables</a>, Up: <a href="c-extensions">Extensions to the C Language Family</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution">
<p class="_attribution-p">
© Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Type-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Type-Attributes.html</a>
</p>
</div>
|