summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/function-attributes.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gcc~13/function-attributes.html')
-rw-r--r--devdocs/gcc~13/function-attributes.html6
1 files changed, 6 insertions, 0 deletions
diff --git a/devdocs/gcc~13/function-attributes.html b/devdocs/gcc~13/function-attributes.html
new file mode 100644
index 00000000..77e91231
--- /dev/null
+++ b/devdocs/gcc~13/function-attributes.html
@@ -0,0 +1,6 @@
+<div class="section-level-extent" id="Function-Attributes"> <div class="nav-panel"> <p> Next: <a href="variable-attributes" accesskey="n" rel="next">Specifying Attributes of Variables</a>, Previous: <a href="mixed-labels-and-declarations" accesskey="p" rel="prev">Mixed Declarations, Labels and Code</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="Declaring-Attributes-of-Functions"><span>6.33 Declaring Attributes of Functions<a class="copiable-link" href="#Declaring-Attributes-of-Functions"> ¶</a></span></h1> <p>In GNU C and C++, you can use function attributes to specify certain function properties that may help the compiler optimize calls or check code more carefully for correctness. For example, you can use attributes to specify that a function never returns (<code class="code">noreturn</code>), returns a value depending only on the values of its arguments (<code class="code">const</code>), or has <code class="code">printf</code>-style arguments (<code class="code">format</code>). </p> <p>You can also use attributes to control memory placement, code generation options or call/return conventions within the function being annotated. Many of these attributes are target-specific. For example, many targets support attributes for defining interrupt handler functions, which typically must follow special register usage and return conventions. Such attributes are described in the subsection for each target. However, a considerable number of attributes are supported by most, if not all targets. Those are described in the <a class="ref" href="common-function-attributes">Common Function Attributes</a> section. </p> <p>Function attributes are introduced by the <code class="code">__attribute__</code> keyword in the declaration of a function, followed by an attribute specification enclosed in double parentheses. You can specify multiple attributes in a declaration by separating them by commas within the double parentheses or by immediately following one attribute specification with another. See <a class="xref" href="attribute-syntax">Attribute Syntax</a>, for the exact rules on attribute syntax and placement. Compatible attribute specifications on distinct declarations of the same function are merged. An attribute specification that is not compatible with attributes already applied to a declaration of the same function is ignored with a warning. </p> <p>Some function attributes take one or more arguments that refer to the function’s parameters by their positions within the function parameter list. Such attribute arguments are referred to as <em class="dfn">positional arguments</em>. Unless specified otherwise, positional arguments that specify properties of parameters with pointer types can also specify the same properties of the implicit C++ <code class="code">this</code> argument in non-static member functions, and of parameters of reference to a pointer type. For ordinary functions, position one refers to the first parameter on the list. In C++ non-static member functions, position one refers to the implicit <code class="code">this</code> pointer. The same restrictions and effects apply to function attributes used with ordinary functions or C++ member functions. </p> <p>GCC also supports attributes on variable declarations (see <a class="pxref" href="variable-attributes">Specifying Attributes of Variables</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>), types (see <a class="pxref" href="type-attributes">Specifying Attributes of Types</a>), and on field declarations (for <code class="code">tainted_args</code>). </p> <p>There is some overlap between the purposes of attributes and pragmas (see <a class="pxref" href="pragmas">Pragmas Accepted by GCC</a>). It has been found convenient to use <code class="code">__attribute__</code> to achieve a natural attachment of attributes to their corresponding declarations, whereas <code class="code">#pragma</code> is of use for compatibility with other compilers or constructs that do not naturally form part of the grammar. </p> <p>In addition to the attributes documented here, GCC plugins may provide their own attributes. </p> <ul class="mini-toc"> <li><a href="common-function-attributes" accesskey="1">Common Function Attributes</a></li> <li><a href="aarch64-function-attributes" accesskey="2">AArch64 Function Attributes</a></li> <li><a href="amd-gcn-function-attributes" accesskey="3">AMD GCN Function Attributes</a></li> <li><a href="arc-function-attributes" accesskey="4">ARC Function Attributes</a></li> <li><a href="arm-function-attributes" accesskey="5">ARM Function Attributes</a></li> <li><a href="avr-function-attributes" accesskey="6">AVR Function Attributes</a></li> <li><a href="blackfin-function-attributes" accesskey="7">Blackfin Function Attributes</a></li> <li><a href="bpf-function-attributes" accesskey="8">BPF Function Attributes</a></li> <li><a href="c-sky-function-attributes" accesskey="9">C-SKY Function Attributes</a></li> <li><a href="epiphany-function-attributes">Epiphany Function Attributes</a></li> <li><a href="h8_002f300-function-attributes">H8/300 Function Attributes</a></li> <li><a href="ia-64-function-attributes">IA-64 Function Attributes</a></li> <li><a href="m32c-function-attributes">M32C Function Attributes</a></li> <li><a href="m32r_002fd-function-attributes">M32R/D Function Attributes</a></li> <li><a href="m68k-function-attributes">m68k Function Attributes</a></li> <li><a href="mcore-function-attributes">MCORE Function Attributes</a></li> <li><a href="microblaze-function-attributes">MicroBlaze Function Attributes</a></li> <li><a href="microsoft-windows-function-attributes">Microsoft Windows Function Attributes</a></li> <li><a href="mips-function-attributes">MIPS Function Attributes</a></li> <li><a href="msp430-function-attributes">MSP430 Function Attributes</a></li> <li><a href="nds32-function-attributes">NDS32 Function Attributes</a></li> <li><a href="nios-ii-function-attributes">Nios II Function Attributes</a></li> <li><a href="nvidia-ptx-function-attributes">Nvidia PTX Function Attributes</a></li> <li><a href="powerpc-function-attributes">PowerPC Function Attributes</a></li> <li><a href="risc-v-function-attributes">RISC-V Function Attributes</a></li> <li><a href="rl78-function-attributes">RL78 Function Attributes</a></li> <li><a href="rx-function-attributes">RX Function Attributes</a></li> <li><a href="s_002f390-function-attributes">S/390 Function Attributes</a></li> <li><a href="sh-function-attributes">SH Function Attributes</a></li> <li><a href="symbian-os-function-attributes">Symbian OS Function Attributes</a></li> <li><a href="v850-function-attributes">V850 Function Attributes</a></li> <li><a href="visium-function-attributes">Visium Function Attributes</a></li> <li><a href="x86-function-attributes">x86 Function Attributes</a></li> <li><a href="xstormy16-function-attributes">Xstormy16 Function Attributes</a></li> </ul> </div> <div class="nav-panel"> <p> Next: <a href="variable-attributes">Specifying Attributes of Variables</a>, Previous: <a href="mixed-labels-and-declarations">Mixed Declarations, Labels and Code</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">
+ &copy; 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/Function-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Function-Attributes.html</a>
+ </p>
+</div>