summaryrefslogtreecommitdiff
path: root/devdocs/c/keyword.html
blob: eff127473370239cd461b56571047a00ffef7a63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    <h1 id="firstHeading" class="firstHeading">C keywords</h1>            <p>This is a list of reserved keywords in C. Since they are used by the language, these keywords are not available for re-definition. <span class="t-rev-inl t-since-c23"><span>As an exception, they are not considered reserved in <a href="language/attributes" title="c/language/attributes"><span class="t-spar">attribute-token</span>s</a></span><span><span class="t-mark-rev t-since-c23">(since C23)</span></span></span></p>
<table class="wikitable"> <tr> <td> <p><a href="keyword/alignas" title="c/keyword/alignas"><code>alignas</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/alignof" title="c/keyword/alignof"><code>alignof</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/auto" title="c/keyword/auto"><code>auto</code></a><br> <a href="keyword/bool" title="c/keyword/bool"><code>bool</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/break" title="c/keyword/break"><code>break</code></a><br> <a href="keyword/case" title="c/keyword/case"><code>case</code></a><br> <a href="keyword/char" title="c/keyword/char"><code>char</code></a><br> <a href="keyword/const" title="c/keyword/const"><code>const</code></a><br> <a href="keyword/constexpr" title="c/keyword/constexpr"><code>constexpr</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/continue" title="c/keyword/continue"><code>continue</code></a><br> <a href="keyword/default" title="c/keyword/default"><code>default</code></a><br> <a href="keyword/do" title="c/keyword/do"><code>do</code></a><br> <a href="keyword/double" title="c/keyword/double"><code>double</code></a><br> <a href="keyword/else" title="c/keyword/else"><code>else</code></a><br> <a href="keyword/enum" title="c/keyword/enum"><code>enum</code></a><br></p>
</td> <td> <p><a href="keyword/extern" title="c/keyword/extern"><code>extern</code></a><br> <a href="keyword/false" title="c/keyword/false"><code>false</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/float" title="c/keyword/float"><code>float</code></a><br> <a href="keyword/for" title="c/keyword/for"><code>for</code></a><br> <a href="keyword/goto" title="c/keyword/goto"><code>goto</code></a><br> <a href="keyword/if" title="c/keyword/if"><code>if</code></a><br> <a href="keyword/inline" title="c/keyword/inline"><code>inline</code></a> <span class="t-mark-rev t-since-c99">(C99)</span><br> <a href="keyword/int" title="c/keyword/int"><code>int</code></a><br> <a href="keyword/long" title="c/keyword/long"><code>long</code></a><br> <a href="keyword/nullptr" title="c/keyword/nullptr"><code>nullptr</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/register" title="c/keyword/register"><code>register</code></a><br> <a href="keyword/restrict" title="c/keyword/restrict"><code>restrict</code></a> <span class="t-mark-rev t-since-c99">(C99)</span><br> <a href="keyword/return" title="c/keyword/return"><code>return</code></a><br> <a href="keyword/short" title="c/keyword/short"><code>short</code></a><br> <a href="keyword/signed" title="c/keyword/signed"><code>signed</code></a><br></p>
</td> <td> <p><a href="keyword/sizeof" title="c/keyword/sizeof"><code>sizeof</code></a><br> <a href="keyword/static" title="c/keyword/static"><code>static</code></a><br> <a href="keyword/static_assert" title="c/keyword/static assert"><code>static_assert</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/struct" title="c/keyword/struct"><code>struct</code></a><br> <a href="keyword/switch" title="c/keyword/switch"><code>switch</code></a><br> <a href="keyword/thread_local" title="c/keyword/thread local"><code>thread_local</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/true" title="c/keyword/true"><code>true</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/typedef" title="c/keyword/typedef"><code>typedef</code></a><br> <a href="keyword/typeof" title="c/keyword/typeof"><code>typeof</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/typeof_unqual" title="c/keyword/typeof unqual"><code>typeof_unqual</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/union" title="c/keyword/union"><code>union</code></a><br> <a href="keyword/unsigned" title="c/keyword/unsigned"><code>unsigned</code></a><br> <a href="keyword/void" title="c/keyword/void"><code>void</code></a><br> <a href="keyword/volatile" title="c/keyword/volatile"><code>volatile</code></a><br> <a href="keyword/while" title="c/keyword/while"><code>while</code></a><br></p>
</td> <td> <p><a href="keyword/_alignas" title="c/keyword/ Alignas"><code>_Alignas</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="keyword/_alignof" title="c/keyword/ Alignof"><code>_Alignof</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="keyword/_atomic" title="c/keyword/ Atomic"><code>_Atomic</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="https://en.cppreference.com/mwiki/index.php?title=c/keyword/_BitInt&amp;action=edit&amp;redlink=1" class="new" title="c/keyword/ BitInt (page does not exist)"><code>_BitInt</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/_bool" title="c/keyword/ Bool"><code>_Bool</code></a> <span class="t-mark-rev t-since-c99">(C99)</span><br> <a href="keyword/_complex" title="c/keyword/ Complex"><code>_Complex</code></a> <span class="t-mark-rev t-since-c99">(C99)</span><br> <a href="keyword/_decimal128" title="c/keyword/ Decimal128"><code>_Decimal128</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/_decimal32" title="c/keyword/ Decimal32"><code>_Decimal32</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/_decimal64" title="c/keyword/ Decimal64"><code>_Decimal64</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="keyword/_generic" title="c/keyword/ Generic"><code>_Generic</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="keyword/_imaginary" title="c/keyword/ Imaginary"><code>_Imaginary</code></a> <span class="t-mark-rev t-since-c99">(C99)</span><br> <a href="keyword/_noreturn" title="c/keyword/ Noreturn"><code>_Noreturn</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="keyword/_static_assert" title="c/keyword/ Static assert"><code>_Static_assert</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br> <a href="keyword/_thread_local" title="c/keyword/ Thread local"><code>_Thread_local</code></a> <span class="t-mark-rev t-since-c11">(C11)</span><br></p>
</td>
</tr>
</table> <p>The most common keywords that begin with an underscore are generally used through their convenience macros:</p>
<table class="wikitable"> <tr> <td>keyword </td> <td>used as </td> <td>defined in </td>
</tr> <tr> <td>
<a href="keyword/_alignas" title="c/keyword/ Alignas"><code>_Alignas</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="types" title="c/types"><code>alignas</code></a> <span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> <td>
<code>stdalign.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_alignof" title="c/keyword/ Alignof"><code>_Alignof</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="types" title="c/types"><code>alignof</code></a> <span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> <td>
<code>stdalign.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_atomic" title="c/keyword/ Atomic"><code>_Atomic</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="thread" title="c/thread"><code>atomic_bool, atomic_int, ...</code></a> </td> <td>
<code>stdatomic.h</code> </td>
</tr> <tr> <td>
<a href="https://en.cppreference.com/mwiki/index.php?title=c/keyword/_BitInt&amp;action=edit&amp;redlink=1" class="new" title="c/keyword/ BitInt (page does not exist)"><code>_BitInt</code></a> <span class="t-mark-rev t-since-c23">(C23)</span> </td> <td>(no macro) </td> <td> </td>
</tr> <tr> <td>
<a href="keyword/_bool" title="c/keyword/ Bool"><code>_Bool</code></a> <span class="t-mark-rev t-since-c99">(C99)</span> </td> <td>
<a href="types" title="c/types"><code>bool</code></a> <span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> <td>
<code>stdbool.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_complex" title="c/keyword/ Complex"><code>_Complex</code></a> <span class="t-mark-rev t-since-c99">(C99)</span> </td> <td>
<a href="numeric/complex/complex" title="c/numeric/complex/complex"><code>complex</code></a> </td> <td>
<code>complex.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_decimal128" title="c/keyword/ Decimal128"><code>_Decimal128</code></a> <span class="t-mark-rev t-since-c23">(C23)</span> </td> <td>(no macro) </td> <td> </td>
</tr> <tr> <td>
<a href="keyword/_decimal32" title="c/keyword/ Decimal32"><code>_Decimal32</code></a> <span class="t-mark-rev t-since-c23">(C23)</span> </td> <td>(no macro) </td> <td> </td>
</tr> <tr> <td>
<a href="keyword/_decimal64" title="c/keyword/ Decimal64"><code>_Decimal64</code></a> <span class="t-mark-rev t-since-c23">(C23)</span> </td> <td>(no macro) </td> <td> </td>
</tr> <tr> <td>
<a href="keyword/_generic" title="c/keyword/ Generic"><code>_Generic</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>(no macro) </td> <td> </td>
</tr> <tr> <td>
<a href="keyword/_imaginary" title="c/keyword/ Imaginary"><code>_Imaginary</code></a> <span class="t-mark-rev t-since-c99">(C99)</span> </td> <td>
<a href="numeric/complex/imaginary" title="c/numeric/complex/imaginary"><code>imaginary</code></a> </td> <td>
<code>complex.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_noreturn" title="c/keyword/ Noreturn"><code>_Noreturn</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="types" title="c/types"><code>noreturn</code></a> </td> <td>
<code>stdnoreturn.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_static_assert" title="c/keyword/ Static assert"><code>_Static_assert</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="error/static_assert" title="c/error/static assert"><code>static_assert</code></a> <span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> <td>
<code>assert.h</code> </td>
</tr> <tr> <td>
<a href="keyword/_thread_local" title="c/keyword/ Thread local"><code>_Thread_local</code></a> <span class="t-mark-rev t-since-c11">(C11)</span> </td> <td>
<a href="thread/thread_local" title="c/thread/thread local"><code>thread_local</code></a> <span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> <td>
<code>threads.h</code> </td>
</tr>
</table> <p>Also, each name that begins with a double underscore <code>__</code> or an underscore <code>_</code> followed by an uppercase letter is reserved: see <a href="language/identifier#Reserved_identifiers" title="c/language/identifier">identifier</a> for details.</p>
<p>Note that digraphs <code>&lt;%</code>, <code>%&gt;</code>, <code>&lt;:</code>, <code>:&gt;</code>, <code>%:</code>, and <code>%:%:</code> provide an <a href="language/operator_alternative" title="c/language/operator alternative">alternative way to represent standard tokens</a>.</p>
<p>The following tokens are recognized by the <a href="preprocessor" title="c/preprocessor">preprocessor</a> when they are used <i>within</i> the context of a preprocessor directive:</p>
<table class="wikitable"> <tr> <td> <p><a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>if</code></a><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>elif</code></a><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>else</code></a><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>endif</code></a><br></p>
</td> <td> <p><a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>ifdef</code></a><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>ifndef</code></a><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>elifdef</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>elifndef</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="preprocessor/replace" title="c/preprocessor/replace"><code>define</code></a><br> <a href="preprocessor/replace" title="c/preprocessor/replace"><code>undef</code></a><br></p>
</td> <td> <p><a href="preprocessor/include" title="c/preprocessor/include"><code>include</code></a><br> <a href="preprocessor/embed" title="c/preprocessor/embed"><code>embed</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="preprocessor/line" title="c/preprocessor/line"><code>line</code></a><br> <a href="preprocessor/error" title="c/preprocessor/error"><code>error</code></a><br> <a href="preprocessor/error" title="c/preprocessor/error"><code>warning</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="preprocessor/impl" title="c/preprocessor/impl"><code>pragma</code></a><br></p>
</td> <td> <p><a href="preprocessor/conditional" title="c/preprocessor/conditional"><code>defined</code></a><br> <a href="preprocessor/include" title="c/preprocessor/include"><code>__has_include</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="preprocessor/embed" title="c/preprocessor/embed"><code>__has_embed</code></a> <span class="t-mark-rev t-since-c23">(C23)</span><br> <a href="language/attributes#Attribute_testing" title="c/language/attributes"><code>__has_c_attribute</code></a> <span class="t-mark-rev t-since-c23">(C23)</span></p>
</td>
</tr>
</table> <p>The following tokens are recognized by the preprocessor when they are used <i>outside</i> the context of a preprocessor directive:</p>
<table class="wikitable"> <tr> <td> <p><a href="preprocessor/impl" title="c/preprocessor/impl"><code>_Pragma</code></a> <span class="t-mark-rev t-since-c99">(C99)</span></p>
</td>
</tr>
</table> <p>The following additional keywords are classified as extensions and conditionally-supported:</p>
<table class="wikitable"> <tr> <td> <p><a href="language/asm" title="c/language/asm"><code>asm</code></a><br> <a href="keyword/fortran" title="c/keyword/fortran"><code>fortran</code></a></p>
</td>
</tr>
</table> <h3 id="References"> References</h3>  <ul>
<li> C23 standard (ISO/IEC 9899:2023): </li>
<ul>
<li> 6.4.1 Keywords (p: TBD) </li>
<li> J.5.9 The fortran keyword (p: TBD) </li>
<li> J.5.10 The asm keyword (p: TBD) </li>
</ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul>
<li> 6.4.1 Keywords (p: 42-43) </li>
<li> J.5.9 The fortran keyword (p: 422) </li>
<li> J.5.10 The asm keyword (p: 422) </li>
</ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 6.4.1 Keywords (p: 58-59) </li>
<li> J.5.9 The fortran keyword (p: 580) </li>
<li> J.5.10 The asm keyword (p: 580) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 6.4.1 Keywords (p: 50) </li>
<li> J.5.9 The fortran keyword (p: 514) </li>
<li> J.5.10 The asm keyword (p: 514) </li>
</ul>
<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
<ul>
<li> 3.1.1 Keywords </li>
<li> G.5.9 The fortran keyword </li>
<li> G.5.10 The asm keyword </li>
</ul>
</ul>                             <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/keyword" title="cpp/keyword">C++ documentation</a></span> for <span class=""><span>C++ keywords</span></span> </td>
</tr> </table>           <div class="_attribution">
  <p class="_attribution-p">
    &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
    <a href="https://en.cppreference.com/w/c/keyword" class="_attribution-link">https://en.cppreference.com/w/c/keyword</a>
  </p>
</div>