Keywords (C++)

Keywords are predefined reserved identifiers that have special meanings. They can't be used as identifiers in your program. The following keywords are reserved for Microsoft C++. Names with leading underscores and names specified for C++/CX and C++/CLI are Microsoft extensions.

Standard C++ keywords

constinit c
continue
co_await c
co_return c
co_yield c
decltype
default
delete
do
double
dynamic_cast
else
enum
explicit
export c
extern
false
float
for
friend
goto
if
inline

a The Microsoft-specific __asm keyword replaces C++ asm syntax. asm is reserved for compatibility with other C++ implementations, but not implemented. Use __asm for inline assembly on x86 targets. Microsoft C++ doesn't support Inline assembly for other targets.

b The extended operator synonyms are keywords when /permissive- or /Za (Disable language extensions) is specified. They aren't keywords when Microsoft extensions are enabled.

c Supported when /std:c++latest is specified.

Microsoft-specific C++ keywords

In C++, identifiers that contain two consecutive underscores are reserved for compiler implementations. The Microsoft convention is to precede Microsoft-specific keywords with double underscores. These words can't be used as identifier names.

Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the /permissive- or /Za (Disable language extensions) option during compilation. These options disable some Microsoft-specific keywords.

When Microsoft extensions are enabled, you can use the Microsoft-specific keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of many of the double-underscored keywords are supported. The __cdecl keyword is available with no leading underscore.

The __asm keyword replaces C++ asm syntax. asm is reserved for compatibility with other C++ implementations, but not implemented. Use __asm.

The __based keyword has limited uses for 32-bit and 64-bit target compilations.

d Intrinsic function used in event handling.

e For backward compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled (the default).

Microsoft keywords in __declspec modifiers

These identifiers are extended attributes for the __declspec modifier. They're considered keywords within that context.

C++/CLI and C++/CX keywords

__abstract f
__box f
__delegate f
__gc f
__identifier
__nogc f
__noop
__pin f
__property f
__sealed f

f Applicable to Managed Extensions for C++ only. This syntax is now deprecated. For more information, see Component Extensions for Runtime Platforms.

g Applicable to C++/CLI.

See also

Lexical conventions
C++ built-in operators, precedence, and associativity