blob: 647c8f8d4a0b25eb198089c5a0bed4046dd0c53a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<div class="section-level-extent" id="Enumerator-Attributes"> <div class="nav-panel"> <p> Next: <a href="statement-attributes" accesskey="n" rel="next">Statement Attributes</a>, Previous: <a href="label-attributes" accesskey="p" rel="prev">Label Attributes</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="Enumerator-Attributes-1"><span>6.37 Enumerator Attributes<a class="copiable-link" href="#Enumerator-Attributes-1"> ¶</a></span></h1> <p>GCC allows attributes to be set on enumerators. See <a class="xref" href="attribute-syntax">Attribute Syntax</a>, for details of the exact syntax for using attributes. Other attributes are available for functions (see <a class="pxref" href="function-attributes">Declaring Attributes of Functions</a>), variables (see <a class="pxref" href="variable-attributes">Specifying Attributes of Variables</a>), labels (see <a class="pxref" href="label-attributes">Label Attributes</a>), statements (see <a class="pxref" href="statement-attributes">Statement Attributes</a>), and for types (see <a class="pxref" href="type-attributes">Specifying Attributes of Types</a>). </p> <p>This example uses the <code class="code">deprecated</code> enumerator attribute to indicate the <code class="code">oldval</code> enumerator is deprecated: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">enum E {
oldval __attribute__((deprecated)),
newval
};
int
fn (void)
{
return oldval;
}</pre>
</div> <dl class="table"> <dt>
<span><code class="code">deprecated</code><a class="copiable-link" href="#index-deprecated-enumerator-attribute"> ¶</a></span>
</dt> <dd>
<p>The <code class="code">deprecated</code> attribute results in a warning if the enumerator is used anywhere in the source file. This is useful when identifying enumerators that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated enumerator, to enable users to easily find further information about why the enumerator is deprecated, or what they should do instead. Note that the warnings only occurs for uses. </p> </dd> <dt>
<span><code class="code">unavailable</code><a class="copiable-link" href="#index-unavailable-enumerator-attribute"> ¶</a></span>
</dt> <dd>
<p>The <code class="code">unavailable</code> attribute results in an error if the enumerator is used anywhere in the source file. In other respects it behaves in the same manner as the <code class="code">deprecated</code> attribute. </p> </dd> </dl> </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/Enumerator-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Enumerator-Attributes.html</a>
</p>
</div>
|