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 Microsoft C++. Names with leading underscores are Microsoft extensions.

__abstract 2

abstract

__alignof Operator

array

__asm

__assume

__based

bool

__box 2

break

case

catch

__cdecl

char

class

const

const_cast

continue

__declspec

default

__delegate 2

delegate

delete

deprecated 1

dllexport 1

dllimport 1

do

double

dynamic_cast

else

enum

enum class

enum struct

event

__event

__except

explicit

extern

false

__fastcall

__finally

finally

float

for

for each, in

__forceinline

friend

friend_as

__gc 2

gcnew

generic

goto

__hook 3

__identifier

if

__if_exists

__if_not_exists

initonly

__inline

inline

int

__int8

__int16

__int32

__int64

__interface

interface class

interface struct

interior_ptr

__leave

literal

long

__m64

__m128

__m128d

__m128i

__multiple_inheritance

mutable

naked 1

namespace

new

new

__nogc 2

noinline 1

__noop

noreturn 1

nothrow 1

novtable 1

nullptr

operator

__pin 2

private

__property 2

property

property 1

protected

public

__raise

ref struct

ref class

register

reinterpret_cast

return

safecast

__sealed 2

sealed

selectany 1

short

signed

__single_inheritance

sizeof

static

static_cast

__stdcall

struct

__super

switch

template

this

__thiscall

thread 1

throw

true

try

__try/__except, __try/__finally

__try_cast 2

typedef

typeid

typeid

typename

__unaligned

__unhook 3

union

unsigned

using declaration, using directive

uuid 1

__uuidof

value struct

value class

__value 2

virtual

__virtual_inheritance

void

volatile

__w64

__wchar_t, wchar_t

 while

1   Extended attributes for the __declspec keyword.

2   Applicable to Managed Extensions for C++ only. This syntax is deprecated in Microsoft Visual C++ 2005.

3   Intrinsic function used in event handling.

See Language Features for Targeting the CLR for information on keywords that are new in Visual C++ 2005.

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.

See Also

Reference

Lexical Conventions

C++ Operators