309 lines
12 KiB
HTML
309 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
|
|
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>C 关键词</title>
|
|
<link rel="stylesheet" href="ext.css" />
|
|
<link rel="stylesheet" href="site_modules.css" />
|
|
</head>
|
|
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-c_keyword skin-cppreference2 action-view cpp-navbar">
|
|
<div id="cpp-content-base">
|
|
<div id="content"><a id="top"></a>
|
|
<h1 id="firstHeading" class="firstHeading">C 关键词</h1>
|
|
<div id="bodyContent">
|
|
<div id="contentSub"><span class="subpages">< <a href="c.html">c</a></span></div>
|
|
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
|
|
<p>这是 C 中保留的关键词列表。因为语言使用这些关键词,故不可重定义它们。</p>
|
|
<table class="wikitable">
|
|
<tr>
|
|
<td>
|
|
<p><a href="c-keyword-auto.html"><code>auto</code></a><br />
|
|
<a href="c-keyword-break.html"><code>break</code></a><br />
|
|
<a href="c-keyword-case.html"><code>case</code></a><br />
|
|
<a href="c-keyword-char.html"><code>char</code></a><br />
|
|
<a href="c-keyword-const.html"><code>const</code></a><br />
|
|
<a href="c-keyword-continue.html"><code>continue</code></a><br />
|
|
<a href="c-keyword-default.html"><code>default</code></a><br />
|
|
<a href="c-keyword-do.html"><code>do</code></a><br />
|
|
<a href="c-keyword-double.html"><code>double</code></a><br />
|
|
<a href="c-keyword-else.html"><code>else</code></a><br />
|
|
<a href="c-keyword-enum.html"><code>enum</code></a><br />
|
|
<a href="c-keyword-extern.html"><code>extern</code></a></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-keyword-float.html"><code>float</code></a><br />
|
|
<a href="c-keyword-for.html"><code>for</code></a><br />
|
|
<a href="c-keyword-goto.html"><code>goto</code></a><br />
|
|
<a href="c-keyword-if.html"><code>if</code></a><br />
|
|
<a href="c-keyword-inline.html"><code>inline</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span><br />
|
|
<a href="c-keyword-int.html"><code>int</code></a><br />
|
|
<a href="c-keyword-long.html"><code>long</code></a><br />
|
|
<a href="c-keyword-register.html"><code>register</code></a><br />
|
|
<a href="c-keyword-restrict.html"><code>restrict</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span><br />
|
|
<a href="c-keyword-return.html"><code>return</code></a><br />
|
|
<a href="c-keyword-short.html"><code>short</code></a></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-keyword-signed.html"><code>signed</code></a><br />
|
|
<a href="c-keyword-sizeof.html"><code>sizeof</code></a><br />
|
|
<a href="c-keyword-static.html"><code>static</code></a><br />
|
|
<a href="c-keyword-struct.html"><code>struct</code></a><br />
|
|
<a href="c-keyword-switch.html"><code>switch</code></a><br />
|
|
<a href="c-keyword-typedef.html"><code>typedef</code></a><br />
|
|
<a href="c-keyword-union.html"><code>union</code></a><br />
|
|
<a href="c-keyword-unsigned.html"><code>unsigned</code></a><br />
|
|
<a href="c-keyword-void.html"><code>void</code></a><br />
|
|
<a href="c-keyword-volatile.html"><code>volatile</code></a><br />
|
|
<a href="c-keyword-while.html"><code>while</code></a></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-keyword-_Alignas.html"><code>_Alignas</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Alignof.html"><code>_Alignof</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Atomic.html"><code>_Atomic</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Bool.html"><code>_Bool</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span><br />
|
|
<a href="c-keyword-_Complex.html"><code>_Complex</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span><br />
|
|
<a href="c-keyword-_Decimal128.html"><code>_Decimal128</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span><br />
|
|
<a href="c-keyword-_Decimal32.html"><code>_Decimal32</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span><br />
|
|
<a href="c-keyword-_Decimal64.html"><code>_Decimal64</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span><br />
|
|
<a href="c-keyword-_Generic.html"><code>_Generic</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Imaginary.html"><code>_Imaginary</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span><br />
|
|
<a href="c-keyword-_Noreturn.html"><code>_Noreturn</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Static_assert.html"><code>_Static_assert</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span><br />
|
|
<a href="c-keyword-_Thread_local.html"><code>_Thread_local</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<p>最常见的以下划线开头的关键词通常通过其便利宏来使用:</p>
|
|
<table class="wikitable">
|
|
<tr>
|
|
<td>关键词</td>
|
|
<td>用作</td>
|
|
<td>定义于</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Alignas.html"><code>_Alignas</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-types.html"><tt>alignas</tt></a></td>
|
|
<td><code>stdalign.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Alignof.html"><code>_Alignof</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-types.html"><tt>alignof</tt></a></td>
|
|
<td><code>stdalign.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Atomic.html"><code>_Atomic</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-atomic.html"><tt>atomic_bool. atomic_int, ...</tt></a></td>
|
|
<td><code>stdatomic.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Bool.html"><code>_Bool</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span></td>
|
|
<td><a href="c-types.html"><tt>bool</tt></a></td>
|
|
<td><code>stdbool.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Complex.html"><code>_Complex</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span></td>
|
|
<td><a href="c-numeric-complex-complex.html"><tt>complex</tt></a></td>
|
|
<td><code>complex.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Decimal128.html"><code>_Decimal128</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span></td>
|
|
<td>(无宏)</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Decimal32.html"><code>_Decimal32</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span></td>
|
|
<td>(无宏)</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Decimal64.html"><code>_Decimal64</code></a> <span class="t-mark-rev t-since-c23">(C23 起)</span></td>
|
|
<td>(无宏)</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Generic.html"><code>_Generic</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td>(无宏)</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Imaginary.html"><code>_Imaginary</code></a> <span class="t-mark-rev t-since-c99">(C99 起)</span></td>
|
|
<td><a href="c-numeric-complex-imaginary.html"><tt>imaginary</tt></a></td>
|
|
<td><code>complex.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Noreturn.html"><code>_Noreturn</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-types.html"><tt>noreturn</tt></a></td>
|
|
<td><code>stdnoreturn.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Static_assert.html"><code>_Static_assert</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-error-static_assert.html"><tt>static_assert</tt></a></td>
|
|
<td><code>assert.h</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="c-keyword-_Thread_local.html"><code>_Thread_local</code></a> <span class="t-mark-rev t-since-c11">(C11 起)</span></td>
|
|
<td><a href="c-thread-thread_local.html"><tt>thread_local</tt></a></td>
|
|
<td><code>threads.h</code></td>
|
|
</tr>
|
|
</table>
|
|
<p>而且,每个以双下划线 __ 或单下划线后随大写字母为首的名称是受保留的:细节参阅<a href="c-language-identifier.html#.E4.BF.9D.E7.95.99.E6.A0.87.E8.AF.86.E7.AC.A6">标识符</a>。</p>
|
|
<p>注意合字符 <code><%</code> 、 <code>%></code> 、 <code><:</code> 、 <code>:></code> 、 <code>%:</code> 以及 <code>%:%:</code> 提供<a href="c-language-operator_alternative.html">表示标准记号的替用方式</a>。</p>
|
|
<p>下列记号在用于<a href="c-preprocessor.html">预处理器</a>指令语境<i>之内</i>时,为预处理器所识别:</p>
|
|
<table class="wikitable">
|
|
<tr>
|
|
<td>
|
|
<p><a href="c-preprocessor-conditional.html"><tt>if</tt></a><br />
|
|
<a href="c-preprocessor-conditional.html"><tt>elif</tt></a><br />
|
|
<a href="c-preprocessor-conditional.html"><tt>else</tt></a><br />
|
|
<a href="c-preprocessor-conditional.html"><tt>endif</tt></a><br /></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-preprocessor-conditional.html"><tt>ifdef</tt></a><br />
|
|
<a href="c-preprocessor-conditional.html"><tt>ifndef</tt></a><br />
|
|
<a href="c-preprocessor-replace.html"><tt>define</tt></a><br />
|
|
<a href="c-preprocessor-replace.html"><tt>undef</tt></a><br /></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-preprocessor-include.html"><tt>include</tt></a><br />
|
|
<a href="c-preprocessor-line.html"><tt>line</tt></a><br />
|
|
<a href="c-preprocessor-error.html"><tt>error</tt></a><br />
|
|
<a href="c-preprocessor-impl.html"><tt>pragma</tt></a><br /></p>
|
|
</td>
|
|
<td>
|
|
<p><a href="c-preprocessor-conditional.html"><tt>defined</tt></a><br />
|
|
<a href="c-language-attributes.html"><tt>__has_c_attribute</tt></a><span class="t-mark-rev t-since-c23">(C23 起)</span></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<p>下列记号用于预处理器指令的语境<i>之外</i>时,为预处理器所识别:</p>
|
|
<table class="wikitable">
|
|
<tr>
|
|
<td>
|
|
<p><a href="c-preprocessor-impl.html"><tt>_Pragma</tt></a><span class="t-mark-rev t-since-c99">(C99 起)</span></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<p>下列的额外关键词被分类为扩展,而且为条件性支持:</p>
|
|
<table class="wikitable">
|
|
<tr>
|
|
<td>
|
|
<p><a href="c-language-asm.html"><tt>asm</tt></a><br />
|
|
<a href="c-keyword-fortran.html"><code>fortran</code></a></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h3><span class="mw-headline" id=".E5.BC.95.E7.94.A8">引用</span></h3>
|
|
<div class="t-ref-std-17">
|
|
<ul>
|
|
<li>C17 标准(ISO/IEC 9899:2018):</li>
|
|
</ul>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>6.4.1 Keywords (p: 42-43)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.9 The fortran keyword (p: 422)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.10 The asm keyword (p: 422)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="t-ref-std-11">
|
|
<ul>
|
|
<li>C11 标准(ISO/IEC 9899:2011):</li>
|
|
</ul>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>6.4.1 Keywords (p: 58-59)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.9 The fortran keyword (p: 580)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.10 The asm keyword (p: 580)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="t-ref-std-c99">
|
|
<ul>
|
|
<li>C99 标准(ISO/IEC 9899:1999):</li>
|
|
</ul>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>6.4.1 Keywords (p: 50)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.9 The fortran keyword (p: 514)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>J.5.10 The asm keyword (p: 514)</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="t-ref-std-c89">
|
|
<ul>
|
|
<li>C89/C90 标准(ISO/IEC 9899:1990):</li>
|
|
</ul>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>3.1.1 Keywords</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>G.5.9 The fortran keyword</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dd>
|
|
<ul>
|
|
<li>G.5.10 The asm keyword</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
|
|
<table class="t-dsc-begin"></table>
|
|
</div>
|
|
<div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|