C keywords

Which are the C keywords and what is their meaning? The answer is below. But let's first clear the term itself.

Keywords (or reserved words) in programming are language-specific words that have special meaning. You cannot use them for names of variables or functions. Note that the term "reserved words" also include words that are reserved for future extensions of the language.

Using C keywords for variable naming is not allowedIf you try to name a variable with a reserved or key word you will get an error

C keywords

The meaning of these words is defined by the language. ANSI C had a small set of keywords. They describe the data types, operations and others. In ANSI C there are 32 keywords, the C99 standard adds 5 and C11 adds 7. Additionally, different compilers may define their own (for instance Microsoft’s Visual Studio defines 19 more).

Keywords defined by ANSI and ISO C90.

Advertise on this site. I promise you will like the rates :)

auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

Words added by ISO C99

Originally, the keywords in C were in lowercase letters only. This was the case with ANSI(which became ISO C90). Later some of the new once started with an underscore and a capital letter. The purpose of this is to keep compatibility with already written code. Since this was an uncommon way for naming in C it is likely that most of the code written through the years does not contain these words.

_Bool _Imaginary restrict
_Complex inline  

Words added by ISO C11

Note that not all compilers support the new keywords. You should check with your compiler before using the new once. It is certain that it will support the 32 words from the ANSI standard and most of the time this is enough.

_Alignas _Generic _Thread_local
_Alignof _Noreturn  
_Atomic _Static_assert  

C Keywords and macros from the standard library

As we said, starting with an underscore and a capital letter is not common for reserved words in C. That’s why usually the new words are used through their macros, which keeps the code style clean.

Keyword Macro Macro defined in
_Alignas alignas stdalign.h
_Alignof alignof stdalign.h
_Atomic Depends on the type
(atomic_bool, atomic_char, atomic_int….)
stdatomic.h
_Bool bool stdbool.h
_Complex complex complex.h
_Imaginary imaginary complex.h
_Noreturn noreturn stdnoreturn.h
_Static_assert static_assert assert.h

The rest of the words don’t have macros in the standard library.

Related reading:   
-    Preprocessor directives, used in C language.
-    The standard library
-    C operators

   Search this site: