Predefined Macros

The C++ compiler recognizes five predefined ANSI C macros, and the Microsoft C++ implementation provides several more. The names of the ANSI predefined macros begin and end with two underscores. These macros take no arguments and cannot be redefined. Their value must be constant throughout compilation.

Table 13.1 Predefined Macros

Identifier Compatibility Value

_CHAR_UNSIGNED Microsoft Defined only when the /J compiler option is given to make char unsigned by default.
__cplusplus ANSI 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 translation date of the current source file. The date is a character string of the form “Mmm dd yyyy”. The quotes are included to form a proper C++ string.

Table 13.1 (continued)

Identifier Compatibility Value

_DLL Microsoft Defined for run-time library as a DLL (/MD compiler option).
_FAST Microsoft Defined if /f option (fast compile) is used.
__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.
_M_I286 Microsoft Defined for 80286 processor (/G2 compiler option).
_M_I386 Microsoft Defined for 80386 processor (flat-model compilation).
_M_I8086 Microsoft Defined for 8086 and 8088 processors (default or /G0 compiler option).
_M_I86 Microsoft Always defined. Identifies target machine as a member of the 8086 family.
_M_I86mM Microsoft Always defined. Identifies memory model, where m is either S (small or tiny model), C (compact model), M (medium 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.”
_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.
_MT Microsoft Defined for multithread library (/MT, /ML, or /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 C 7.0, the __STDC__ macro is used instead.
__PCODE Microsoft Defined for sections of code that are compiled as p-code.

Table 13.1 (continued)

Identifier Compatibility Value

_QC Microsoft Defined if /f option (fast compile) is used.
__STDC__ ANSI C 1 if /Za (ANSI-conformance) option is used; otherwise undefined.
__TIME__ ANSI C, C++ The translation time of the current 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 translation unit. 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.