C语言关键词
ISO/IEC 9899:2024标准提供了54个C语言关键词,具体如下表所示:
| alignas | do | int | struct | while |
| alignof | double | long | switch | _Atomic |
| auto | else | nullptr | thread_local | _BitInt |
| bool | enum | register | true | _Complex |
| break | extern | restrict | typedef | _Decimal128 |
| case | false | return | typeof | _Decimal32 |
| char | float | short | typeof_unqual | _Decimal64 |
| const | for | signed | union | _Generic |
| constexpr | goto | sizeof | unsigned | _Imaginary |
| continue | if | static | void | _Noreturn |
| default | inline | static_assert | volatile |
上述标记区分大小写,保留用作C语言关键词,但属性标记(attribute token)除外,不得用于其它用途。关键词_Imaginary用于指定虚数类型。
下表提供了一些关键词的替代拼写。
| 关键词 | 替代拼写 |
| alignas | _Alignas |
| alignof | _Alignof |
| bool | _Bool |
| static_assert | _Static_assert |
| thread_local | _Thread_local |
这些替代拼写是ISO/IEC 9899:2018标准中的C语言关键词;根据ISO/IEC 9899:2024标准,这些替代拼写已经过时,不建议用于新代码。
主要参考资料: