C++ Keywords

Keywords are predefined reserved identifiers that have special meanings. They cannot be used as identifiers in your program. The following keywords are reserved for C++:

Syntax

keyword: one of

asm1 auto bad_cast bad_typeid
bool break case catch
char class const const_cast
continue default delete do
double dynamic_cast else enum
except explicit extern false
finally float for friend
goto if inline int
long mutable namespace new
operator private protected public
register reinterpret_cast return short
signed sizeof static static_cast
struct switch template this
throw true try type_info
typedef typeid typename union
unsigned using virtual void
volatile while

1   Reserved for compatibility with other C++ implementations, but not implemented. Use __asm.

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.

allocate3 __inline property3
__asm1 __int8 selectany3
__based2 __int16 __single_inheritance
__cdecl __int32 __stdcall
__declspec __int64 thread3
dllexport3 __leave __try
dllimport3 __multiple_inheritance uuid3
__except naked3 __uuidof
__fastcall nothrow3 __virtual_inheritance
__finally

1   Replaces C++ asm syntax.

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

3   These are special identifiers when used with __declspec; their use in other contexts is not restricted.

Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the ANSI-compatible /Za command-line option (compile for ANSI compatibility) during compilation. When you do this, Microsoft-specific keywords are disabled.

When Microsoft extensions are enabled, you can use the previously-listed keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of all the keywords except __except, __finally, __leave, and __try are supported. In addition, __cdecl is available with no leading underscore.

END Microsoft Specific