Skip to content
Tutorials Center
My learning

Topics

C Reference ยท Keywords and Statements

C reserved words (keywords)

The complete list of C keywords through C23, grouped by purpose, with the old underscore spellings, the rules for reserved identifiers and what you cannot name things.

A keyword is a word with a fixed meaning in the C language. You cannot use it as the name of a variable, function, struct tag or macro. C has about 50 keywords, and the list has grown slowly: C99 and C11 added words starting with an underscore and a capital letter, such as _Bool and _Static_assert, so that old programs that used names like bool would keep compiling. C23 promoted many of them to plain keywords.

Beyond keywords, the standard also reserves whole families of identifiers for the implementation. Knowing both rules keeps your names from clashing with the compiler and the library.

C
int class = 3;      /* fine in C, a keyword in C++ */
int register = 1;   /* error: register is a keyword */

Try it

C C23 words that used to be macros

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

C Names that look like keywords but are not

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

The keywords

Keywords are case sensitive and always lowercase, except for the older underscore forms.

Group Keywords
Types char short int long float double signed unsigned void bool _Complex _Imaginary _BitInt _Decimal32 _Decimal64 _Decimal128
Type declarations struct union enum typedef
Qualifiers const volatile restrict _Atomic
Storage and linkage auto register static extern thread_local inline
Control flow if else switch case default for while do break continue goto return
Operators sizeof alignof typeof typeof_unqual _Generic
Declarations alignas constexpr static_assert _Noreturn
Constants true false nullptr

Old and new spellings

C23 keyword Older spelling Notes
bool, true, false _Bool, macros in <stdbool.h> <stdbool.h> still works and does nothing now.
alignas, alignof _Alignas, _Alignof Macros in <stdalign.h> before C23.
static_assert _Static_assert The message is optional in C23.
thread_local _Thread_local Macro in <threads.h> before C23.
constexpr, nullptr, typeof none Brand new in C23 (typeof was a GNU extension).
[[noreturn]] _Noreturn _Noreturn is obsolescent; see Attributes.

The old spellings remain valid, so portable code can still use them.

Reserved identifiers

Besides keywords, these names belong to the implementation:

  • Any identifier starting with two underscores, or an underscore followed by an uppercase letter (__x, _Foo), in every scope.
  • Any identifier starting with a single underscore at file scope (global variables and functions, and typedef names).
  • Every name declared in a standard header you include, and the standard names for macros (NULL, EOF, INT_MAX).
  • Names starting with str, mem, is, to followed by a lowercase letter, E followed by a digit or uppercase letter, SIG, FE_ and others, which the standard may use for future library additions.

Defining your own macro with a keyword's name, as in #define int long, is undefined behavior if any standard header is included afterwards.

Usage notes

  • Predefined, not keywords: main, printf, NULL, EOF, size_t and FILE are ordinary identifiers. You can shadow them, but you should not.
  • C and C++ differ. class, new, delete, this, template, namespace and try are legal C identifiers but break the program when compiled as C++. Avoid them in headers meant for both languages.
  • bool before C23: with -std=c17 or earlier, bool needs #include <stdbool.h>.
  • Compilers add extensions such as __attribute__, asm, __typeof__ and __int128. In strict modes such as -std=c17, GCC does not recognize plain asm; use __asm__ there.
  • Check the mode. __STDC_VERSION__ is 202311L for C23, 201710L for C17 and 201112L for C11.
  • Style: pick names that are descriptive and avoid leading underscores entirely.