Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
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:
__asm
5
__based
3, 5
__cdecl
5
__declspec
5
__except
5
__fastcall
__finally
5
__inline
5
__int16
5
__int32
5
__int64
5
__int8
5
__leave
5
__restrict
__stdcall
5
__try
5
__typeof__
__typeof_unqual__
dllexport
4
dllimport
4
naked
4
static_assert
6
thread
4
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.