digitalmars.com                        
Last update Sun Sep 8 21:42:01 2013

Predefined Macros

Numerous macros are predefined by the compiler, enabling detailed control for conditional compilation.

Names without a leading _ will not be defined if the -A switch is used. New code should use the leading _ version.

By "defined", a macro is defined and set to 1.

_MSDOS, MSDOS
MSDOS target. Defined for all cases where __OS2__ or _WIN32 are not defined.
__OS2__
OS/2 target. Defined for -mf.
WIN32,_WIN32
WIN32 target (NT, Windows 95 or Win32s). Defined for -mn.
DOS386
32 bit extended DOS target. Defined for -mx or -mp.
DOS16RM
16 bit extended DOS target. Defined for -mr or -mz.
M_I86, _M_I86
Always defined.
_M_I86TM, M_I86TM
Tiny memory model. Defined for -mt.
_M_I86SM, M_I86SM
Small memory model. Defined for -ms, -mx, -mp, -mf or -mn.
_M_I86MM, M_I86MM
Medium memory model. Defined for -mm.
_M_I86CM, M_I86CM
Compact memory model. Defined for -mc.
_M_I86LM, M_I86LM
Large memory model. Defined for -ml, -mr or -mz.
_M_I86VM, M_I86VM
VCM memory model. Defined for -mv.
_M_I8086, M_I8086
8088 is target. Defined for -0 or default for -mt, -ms, -mm, -mc, -ml, or -mv.
_M_I286, M_I286
80286 or better is target. Defined for -2, -3, -4, -5. Default for -mr, -mz, -mx, -mp, -mf, -mo.
_M_IX86
Defined for 32 bit targets. Set to: 300 for 386 targets, 400 for 486, 500 for Pentium, 600 for P6.
__DMC__
Always defined. Set to version number: 0x700 for version 7.0, 0x720 for 7.2, 0x800 for 8.0.
__DMC_VERSION_STRING__
Expands to a string identifying the compiler, such as "Digital Mars C/C++ 8.32.2".
_CHAR_UNSIGNED
Chars are unsigned. Defined for -J.
_CHAR_EQ_UCHAR
chars and unsigned chars are same type. Defined for -Ju.
_DEBUG_TRACE
Set to 1 when -gt is set.
_DLL
Set to 1 when -ND is set. Means that the DLL RTL will be used rather than the statically linked in RTL.
_ENABLE_ARRAYNEW
Set to 1 when -Aa is set.
_BOOL_DEFINED
Set to 1 for -Ab (enable bool keyword).
_WCHAR_T_DEFINED
Set to 1 for -Aw (enable wchar_t keyword).
_CPPRTTI
Set to 1 for -Ar (enable RTTI).
_CPPUNWIND
Set to 1 for -Ae (enable C++ exception handling).
_MD
Set to 1 when -ND is set. Means that the app will be multi-thread aware.
_PUSHPOP_SUPPORTED
Set to 1. Used to indicate #pragma pack(push) and #pragma pack(pop) are supported.
_STDCALL_SUPPORTED
Set to 1. Used to indicate that the __stdcall and __cdecl keywords are supported.
__INTSIZE
Always defined. Set to size of int (2 for 16 bit models, 4 for 32 bit models). This macro is equivalent to sizeof(int) except that it can be used in preprocessor expressions. It is most useful for distinguishing between 16-and 32-bit compilations. For example:
#if __INTSIZE == 2
    // 16-bit version
#elseif __INTSIZE == 4
    // 32-bit version 
#else
#error Unsupported int size 
#endif 
__DEFALIGN
Always defined. Set to default struct member alignment for memory model. Not affected by -a compiler switch or align or pack pragmas. It is affected by the memory model. It has a value of 2 for 16-bit memory models, 4 for DOSX, and 8 for Win32.

It is useful for ensuring that structures in header files are laid out in a manner consistent with their corresponding compiled library. For example:

#pragma pack(__DEFALIGN) // to default alignment 
struct ABC {...}; // lay out structure
#pragma pack() // return to previous alignment 
_INTEGRAL_MAX_BITS
Set to 32 for 16 bit memory models, 64 for 32 bit memory models. It specifies the maximum number of bits in the largest integral type. (32 bit memory models support the long long 64 bit integral type.)
_WINDOWS
Generating Windows program. Defined for -W[123AD].
_WINDLL
Generating Windows DLL. Defined for -WD.
__INLINE_8087
Defined if generating inline math coprocessor code.
__I86__
Always defined. Set to target CPU (0 == 8088, 2 == 286, 3 == 386, 4 == 486, 5 == P5, 6 == P6).
__SMALL__
Defined if -mt, -ms, -mx, -mp, -mf, -mn.
__MEDIUM__
Defined if -mm.
__COMPACT__
Defined if -mc.
__LARGE__
Defined if -ml, -mz, -mr.
__VCM__
Defined if -mv.
__FPCE__
Always defined. Indicates NCEG conformance.
__FPCE__IEEE__
Indicates IEEE 754 conformance. Defined by default, not defined for -ff.
DEBUG
Defined for -D. Not affected by -A.
__BASE_FILE__
Source file name as specified on the command line.
__FUNCTION__
Same as __FUNC__. Provided for Gnu CC compatibility.
__PRETTY_FUNCTION__
Same as __FUNC__, but pretty-printed (C++ functions become more readable). Provided for Gnu CC compatibility.
__TIMESTAMP__
Always defined. Set to compilation time in the form "Ddd Mmm dd hh:mm:ss yyyy".

C99 Predefined Macros

Defined per the C99 Standard 6.10.8 when compiling C programs.
__DATE__
Always defined. Set to compilation date in the form "Mmm dd yyyy".
__FILE__
Always defined. Set to name of file being compiled enclosed in "".
__LINE__
Always defined. Set to current line of source file.
__STDC__
C standard conformance. Defined for -A, -A89, -A90, -A94, -A95, -A99 and set to 1.
__STDC_HOSTED__
Always defined and set to 0.
__STDC_VERSION__
Always defined (unless switch -A89 or -A90) and set to 19990L (199409L for switch -A94 or -A95).
__TIME__
Always defined. Set to compilation time in the form "hh:mm:ss".
__STDC_IEC_559__
IEC 60559 floating point arithmetic conformance. Defined if -ff (fast floating point) is not set. If defined, then set to 1.
__STDC_IEC_559_COMPLEX__
IEC 60559 complex floating point arithmetic conformance. Defined if -ff (fast floating point) is not set. If defined, then set to 1.
__STDC_ISO_10646__
Not defined.

C++98 Predefined Macros

Defined per the C++98 Standard 16.8-1 when compiling C++ programs (.cpp file extension or -cpp switch).
__LINE__
Always defined. Set to current line of source file.
__FILE__
Always defined. Set to name of file being compiled enclosed in "".
__DATE__
Always defined. Set to compilation date in the form "Mmm dd yyyy".
__TIME__
Always defined. Set to compilation time in the form "hh:mm:ss".
__STDC__
C++98 conformance. Defined for -A and set to 1.
__cplusplus
Always defined and set to 199711L.

Obsolete Predefined Macros

These are retained for backwards compatibility. They should not be used in new code.
__FUNC__
Always defined. Expands to the name of the function. The name appears enclosed in "". Expands to "" outside of a function. Obsolete per C99 6.4.2.2; use __func__ instead.
__NT__
Windows NT or Win32s target. Defined for -mn. Obsolete - use _WIN32 instead.
__SC__
Always defined. Set to same value as __DMC__. Obsolete - use __DMC__ instead.
__ZTC__
Always defined. Set to same value as __DMC__. Obsolete - use __DMC__ instead.
Home | Runtime Library | IDDE Reference | STL | Search | Download | Forums