
01Introduction:
In the previous article, we discussed three keywords in C language. Liu thought about it and wondered what other keywords exist in C language. After gathering some information, the summary is as follows, based on different standards.
02C89/C90 Standard (32 Keywords)
|
035 New Keywords Added in C99 Standard
| Keyword | Usage |
|---|---|
<span>_Bool</span> |
Boolean type (requires inclusion of <span><stdbool.h></span>) |
<span>_Complex</span> |
Complex type (requires inclusion of <span><complex.h></span>) |
<span>_Imaginary</span> |
Imaginary type (requires inclusion of <span><complex.h></span>) |
<span>inline</span> |
Inline function declaration |
<span>restrict</span> |
Pointer qualifier (optimizes memory access) |
047 New Keywords Added in C11 Standard
| Keyword | Usage |
|---|---|
<span>_Alignas</span> |
Memory alignment specification |
<span>_Alignof</span> |
Get memory alignment value |
<span>_Atomic</span> |
Support for atomic operations |
<span>_Generic</span> |
Generic selection expression |
<span>_Noreturn</span> |
Marks a function that does not return |
<span>_Static_assert</span> |
Static assertion at compile time |
<span>_Thread_local</span> |
Thread-local storage |
03Conclusion
//C89/C90
auto break case char const continue
default do double else enum extern
float for goto if int long
register return short signed sizeof static
struct switch typedef union unsigned void
volatile while
// C99 New Keywords
_Bool _Complex _Imaginary inline restrict
// C11 New Keywords
_Alignas _Alignof _Atomic _Generic _Noreturn
_Static_assert _Thread_local
Notes:
-
Distinguishing Standards:
- C89/C90 is the classic standard, supported by all compilers.
- C99/C11 new keywords require compiler support (e.g., GCC uses
<span><span>-std=c99</span></span>or<span><span>-std=c11</span></span>to enable).
Disabled Identifiers: Keywords cannot be used as variable names or function names (e.g., <span><span>int float;</span></span> is illegal).
Common Confusions:
<span><span>main</span></span>is not a keyword, but a predefined function name.<span><span>true</span></span>/<span><span>false</span></span>are macros in<span><span><stdbool.h></span></span>, not keywords.- __IO is not a keyword.
- __nop() is not a keyword.