| title | C Keywords | |||
|---|---|---|---|---|
| ms.date | 10/09/2018 | |||
| helpviewer_keywords |
|
|||
| ms.assetid | 2d932335-97bf-45cd-b367-4ae00db0ff42 |
"Keywords" are words that have special meaning to the C compiler. In translation phases 7 and 8, an identifier cannot have the same spelling and case as a C keyword. (See a description of translation phases in the Preprocessor Reference; for information on identifiers, see Identifiers.) The C language uses the following keywords:
:::row:::
:::column:::
auto
double
int
struct
break
else
long
switch
:::column-end:::
:::column:::
case
enum
register
typedef
char
extern
return
union
:::column-end:::
:::column:::
const
float
short
unsigned
continue
for
signed
void
:::column-end:::
:::column:::
default
goto
sizeof
volatile
do
if
static
while
:::column-end:::
:::row-end:::
You can't redefine keywords. However, you can specify text to be substituted for keywords before compilation by using C preprocessor directives.
Microsoft Specific
The ANSI C standard allows identifiers with two leading underscores to be reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keyword names with double underscores. These words cannot be used as identifier names. For a description of the ANSI 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:
:::row:::
:::column:::
__asm3
dllimport2
__int83
naked2
__based1, 3
:::column-end:::
:::column:::
__except3
__int163
__stdcall3
__cdecl3
__fastcall
:::column-end:::
:::column:::
__int323
thread2
__declspec3
__finally3
__int643
:::column-end:::
:::column:::
__try3
dllexport2
__inline3
__leave3
:::column-end:::
:::row-end:::
1 The __based keyword has limited uses for 32-bit and 64-bit target compilations.
2 These are special identifiers when used with __declspec; their use in other contexts is not restricted.
3 For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the /Za (Disable language extensions) option during compilation. When you do this, some Microsoft-specific keywords are disabled.
When Microsoft extensions are enabled, you can use the keywords listed above in your programs. For ANSI compliance, most of these keywords are prefaced by a double underscore. The four exceptions, dllexport, dllimport, naked, and thread, are used only with __declspec and therefore do not require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
END Microsoft Specific