Keywords (C++)

Keywords are predefined reserved identifiers that have special meanings. They cannot be used as identifiers in your program. The following keywords are reserved for Microsoft C++. Names with leading underscores are Microsoft extensions.

__abstract 2 __alignof Operator 4 __asm 4 __assume 4
__based 4 __box 2 __cdecl 4 __declspec 4
__delegate 2 __event __except 4 __fastcall 4
__finally 4 __forceinline 4 __gc 2 __hook 3
__identifier __if_exists __if_not_exists __inline 4
__int16 4 __int32 4 __int64 4 __int8 4
__interface __leave 4 __m128 __m128d
__m128i __m64 __multiple_inheritance 4 __nogc 2
__noop __pin 2 __property 2 __ptr32 4
__ptr644 __raise __restrict 4 __sealed 2
__single_inheritance4 __sptr4 __stdcall 4 __super
__thiscall __try_cast 2 __unaligned 4 __unhook 3
__uptr 4 __uuidof 4 __value 2 __vectorcall 4
__virtual_inheritance 4 __w64 4 __wchar_t abstract
alignas array auto bool
break case catch char
char16_t char32_t class const
const_cast constexpr continue decltype
default delegate delete deprecated 1
dllexport 1 dllimport 1 do double
dynamic_cast else enum enum class
enum struct event explicit extern
false finally float for
for each in friend friend_as gcnew
generic goto if initonly
inline int interface class interface struct
interior_ptr literal long mutable
naked 1 namespace new new
noexcept noinline 1 noreturn 1 nothrow 1
novtable 1 nullptr operator private
property property 1 protected public
ref class ref struct register reinterpret_cast
return safecast sealed selectany 1
short signed sizeof static
static_assert static_cast struct switch
template this thread 1 throw
true try typedef typeid
typeid typename union unsigned
using declaration using directive uuid 1 value class
value struct virtual void volatile
while

1 Extended attributes for the __declspec keyword.

2 Applicable to Managed Extensions for C++ only. This syntax is now deprecated. See Component Extensions for Runtime Platforms for more information.

3 Intrinsic function used in event handling.

4 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 Specific

In Microsoft C++, identifiers with two leading underscores are reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keywords with double underscores. These words cannot 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 /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 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. In addition, __cdecl 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.

END Microsoft Specific

See also

Lexical Conventions
C++ Built-in Operators, Precedence and Associativity