Keywords are predefined reserved identifiers that have special meanings. They cannot be used as identifiers in your program.
The second section of keywords below are particular to Microsoft C++; these keywords are disabled when the /Za (ANSI-conformance) option is used during compilation.
keyword: one of
asm7autobreakcasecatch8charclassconstcontinuedefaultdeletedodoubleelseenumexternfloatforfriendgotoifinlineintlongnewoperatorprivateprotectedpublicregisterreturnshortsignedsizeofstaticstructswitchtemplate8thisthrow8try8typedefunionunsignedvirtualvoidvolatilewhile
__asm1,2__based1,3__cdecl1__emit1,5__except1,6__export1__far1__fastcall1,4__finally1,6__fortran1,4__huge1,4__interrupt1__loadds1,4__near1__pascal1,4__saveregs1,4__segment1,4__segname1__self1__stdcall1__syscall1__try1,6
1Microsoft-specific keyword.
2Replaces C++ asm syntax.
3The __based keyword has limited uses for 32-bit target compilations. In such compilations, __based is supported syntactically and for disambiguation purposes, but only the declaration of objects based on a pointer is supported semantically. Types that are based on a pointer are considered 32-bit displacements to a 32-bit base.
4Supported syntactically and for disambiguation purposes, but not meaningful in 32-bit compilations.
5__emit is not, strictly speaking, a keyword; rather it is a pseudoinstruction for the inline assembler. __emit is not supported for 32-bit compilations.
6Microsoft structured exception-handling keywords, __try, __except, and __finally are meaningful only for 32-bit targets.
7Reserved for compatibility with other C++ implementations, but not implemented. Use __asm.
8Not implemented in Microsoft C/C++ version 7.0.
Note:
The Microsoft extended keywords listed above are prefaced with a double underscore for ANSI compliance. For backward compatibility, however, the single-underscore versions of these keywords are supported unless the /Za (ANSI compliance) compilation option is specified.
Note that the keywords near, far, huge, cdecl, fortran, pascal, and interrupt are available with no leading underscores unless the /Za (ANSI compliance) compilation option is specified.
In addition to the C++ keywords shown above, Microsoft C++ defines the names in Table 1.1 as macros. Some of these macros can be tested using the #ifdef or #ifdefined preprocessor directive.
Table 1.1 Microsoft C/C++ Predefined Identifiers
Identifier | Compatibility | Value |
__cplusplus | C++ | The value of this macro is not significant. If it is defined, the program is compiled as C++. This macro is not defined for translation units compiled as C. |
__DATE__ | ANSI C, C++ | The date of compilation of the source file. The date is a character string of the form "Mmm dd yyyy". The quotes are included to form a proper C++ string. |
__FILE__ | ANSI C, C++ | The name of the current source file. __FILE__ expands to a string surrounded by double quotes. |
__LINE__ | ANSI C, C++ | The line number in the current source file. The line number is a decimal number. |
__STDC__ | ANSI C | Defined equal to 1 only if /Za (ANSI-conformance) compilation option used; otherwise undefined. |
__TIME__ | ANSI C, C++ | The time of compilation of the source file. The time is a character string of the form "hh:mm:ss". The quotes are included to form a proper C++ string. |
__TIMESTAMP__ | Microsoft | The date and time of translation of the current source file. The timestamp is a character string of the form "Ddd Mmm dd hh:mm:ss". The quotes are included to form a proper C++ string. |
_MSC_VER | Microsoft | Defines the compiler version as a string literal in the form ddd. For Microsoft C/C++ version 7.0, the string is "700". |
_MSDOS | Microsoft | Always defined. Identifies target operating system as MS-DOS. |
_M_I86 | Microsoft | Always defined. Identifies target machine as a member of the 8086 family. |
_M_I8086 | Microsoft | Defined when compilation targets 8086 and 8088 processors (default or /G0 compiler option). |
Table 1.1 (continued)
Identifier | Compatibility | Value |
_M_I286 | Microsoft | Defined when compilation targets 80286 processor (/G2 compiler option). |
_M_I386 | Microsoft | Defined when compilation targets 80386 processor (/G3 flat-model compilation—not available on compilers that target 16-bit applications). |
_M_I86mM | Microsoft | Always defined. Identifies memory model, where m is either S (small or tiny model), M (Medium model), C (compact model), L (large model), or H (huge model). If huge model is used, both _M_I86LM and _M_I86HM are defined. |
Small model is the default. For more information about memory models, see Appendix B, “Microsoft-Specific Modifiers.” | ||
__DLL | Microsoft | Defined for run-time library as a DLL (/MD compiler option). |
NO_EXT_KEYS | Microsoft | No longer emitted by the compiler. This macro was defined in previous versions of Microsoft C for compilations that used the /Za (ANSI-conformance) option. In Microsoft C/C++ version 7.0, the __STDC__ macro is used instead. |
_CHAR_UNSIGNED | Microsoft | Defined only when the /J compiler option is given to make char unsigned by default. |