C Keywords

Keywords are words that have special meaning to the C compiler. In translation phases 7 and 8, an identifier can't have the same spelling and case as a C keyword. For more information, see translation phases in the Preprocessor Reference. For more information on identifiers, see Identifiers.

Standard C keywords

The C language uses the following keywords:

auto
break
case
char
const
continue
default
do
double
else
enum

extern
float
for
goto
if
inline 1, a
int
long
register
restrict 1, a
return

short
signed
sizeof
static
struct
switch
typedef
typeof
typeof_unqual
union
unsigned
void
volatile

while
_Alignas 2, a
_Alignof 2, a
_Atomic 2, b
_Bool 1, a
_Complex 1, b
_Generic 2, a
_Imaginary 1, b
_Noreturn 2, a
_Static_assert 2, a
_Thread_local 2, b

1 Keywords introduced in ISO C99.
2 Keywords introduced in ISO C11.
a Starting in Visual Studio 2019 version 16.8, these keywords are supported in code compiled as C when the /std:c11 or /std:c17 compiler options are specified.
b Starting in Visual Studio 2019 version 16.8, these keywords are recognized but not supported by the compiler in code compiled as C when the /std:c11 or /std:c17 compiler options are specified.

You can't redefine keywords. However, you can specify text to replace keywords before compilation by using C preprocessor directives.

Microsoft-specific C keywords

The ANSI and ISO C standards allow identifiers with two leading underscores to be reserved for compiler implementations. The Microsoft convention is to precede Microsoft-specific keyword names with double underscores. These words can't be used as identifier names. For a description of the rules for naming identifiers, including the use of double underscores, see Identifiers.

The following keywords and special identifiers are recognized by the Microsoft C compiler:

__asm5
__based3, 5
__cdecl5
__declspec5
__except5
__fastcall
__finally5

__inline5
__int165
__int325
__int645
__int85
__leave5
__restrict

__stdcall5
__try5
__typeof__
__typeof_unqual__
dllexport4
dllimport4
naked4
static_assert6
thread4

3 The __based keyword has limited uses for 32-bit and 64-bit target compilations.
4 These are special identifiers when used with __declspec; their use in other contexts is unrestricted.
5 For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
6 If you don't include <assert.h>, the Microsoft Visual C compiler maps static_assert to the C11 _Static_assert keyword.

Microsoft extensions are enabled by default. To help create portable code, you can disable Microsoft extensions by specifying the /Za (Disable language extensions) option during compilation. When you use this option, some Microsoft-specific keywords are disabled.

When Microsoft extensions are enabled, you can use the keywords listed above in your programs. To conform to the language standard, most of these keywords have a leading double underscore. The four exceptions, dllexport, dllimport, naked, and thread, are used only with __declspec and don't require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.

See also

Elements of C