Skip to content

Latest commit

 

History

History
86 lines (71 loc) · 8.57 KB

keywords-cpp.md

File metadata and controls

86 lines (71 loc) · 8.57 KB
title Keywords (C++) | Microsoft Docs
ms.custom index-page
ms.date 09/18/2018
ms.technology
cpp-language
ms.topic language-reference
dev_langs
C++
helpviewer_keywords
Visual C++, keywords
keywords [C++]
__identifer keyword [C++], naming
Microsoft-specific keywords
__identifer keyword [C++]
ms.assetid d7ca94a8-f785-41ce-9f73-d3c4fd508489
author mikeblome
ms.author mblome
ms.workload
cplusplus

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 __asm
__based __box 2 __cdecl
__delegate 2 __event __except
__finally __forceinline __gc 2
__identifier __if_exists __if_not_exists
__int16 __int32 __int64
__interface __leave __m128
__m128i __m64 __multiple_inheritance
__noop __pin 2 __property 2
__thiscall __try/__except __try/__finally
__unaligned __unhook 3 __uuidof
__virtual_inheritance __w64 __wchar_t
alignas array auto
break case catch
char16_t char32_t class
const_cast constexpr continue
default delegate delete
dllexport 1 dllimport 1 do
dynamic_cast else enum
enum struct event explicit
false finally float
for each in friend friend_as
gcnew generic goto
initonly inline int
interface struct interior_ptr literal
mutable naked 1 namespace
new noexcept noinline 1
nothrow 1 novtable 1 nullptr
private property property 1
public ref class ref struct
reinterpret_cast return safecast
selectany 1 short signed
static static_assert static_cast
switch template this
throw true try
typeid typeid typename
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.

3 Intrinsic function used in event handling.

See Component Extensions for Runtime Platforms for more information.

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 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 Microsoft-specific keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of all the double-underscored keywords except __except, __finally, __leave, and __try 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