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
alignas
alignof
and
b
and_eq
b
asm
a
auto
bitand
b
bitor
b
bool
break
case
catch
char
char8_t
c
char16_t
char32_t
class
compl
b
concept
c
const
const_cast
consteval
c
constexpr
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++20
or later (such as /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 conformance, 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.
__alignof
e
__asm
e
__assume
e
__based
e
__cdecl
e
__declspec
e
__event
__except
e
__fastcall
e
__finally
e
__forceinline
e
__hook
d
__if_exists
__if_not_exists
__inline
e
__int16
e
__int32
e
__int64
e
__int8
e
__interface
__leave
e
__m128
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
__try_cast
f
__value
f
abstract
g
array
g
as_friend
delegate
g
enum class
enum struct
event
g
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