Predefined Macros
Names the predefined ANSI C and Microsoft C++ implementation macros.
The compiler recognizes predefined ANSI C macros and the Microsoft C++ implementation provides several more. These macros take no arguments and cannot be redefined. Some of the predefined macros listed below are defined with multiple values. See the following tables for more information.
Macro | Description |
---|---|
__DATE__ |
The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H. |
__FILE__ |
The name of the current source file. __FILE__ expands to a string surrounded by double quotation marks. To ensure that the full path to the file is displayed, use /FC (Full Path of Source Code File in Diagnostics). You can create your own wide string version of __FILE__ as follows: |
__LINE__ |
The line number in the current source file. The line number is a decimal integer constant. It can be altered with a #line directive. |
__STDC__ |
Indicates full conformance with the ANSI C standard. Defined as the integer constant 1 only if the /Za compiler option is given and you are not compiling C++ code; otherwise is undefined. |
__TIME__ |
The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss. |
__TIMESTAMP__ |
The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy, where Ddd is the abbreviated day of the week and Date is an integer from 1 to 31. |
Macro | Description |
---|---|
_ATL_VER |
Defines the ATL version. |
_CHAR_UNSIGNED |
Default char type is unsigned. Defined when /J is specified. |
__CLR_VER |
Defines the version of the common language runtime used when the application was compiled. The value returned will be in the following format: Mmmbbbbb where, M is the major version of the runtime. mm is the minor version of the runtime. bbbbb is the build number. |
__cplusplus_cli |
Defined when compiling with /clr, /clr:pure, or /clr:safe. Value of __cplusplus_cli is 200406. __cplusplus_cli is in effect throughout the translation unit. |
__COUNTER__ |
Expands to an integer starting with 0 and incrementing by 1 every time it is used in a compiland. __COUNTER__ remembers its state when using precompiled headers. If the last __COUNTER__ value was 4 after building a precompiled header (PCH), it will start with 5 on each PCH use. __COUNTER__ lets you generate unique variable names. You can use token pasting with a prefix to make a unique name. For example: // pre_mac_counter.cpp #include <stdio.h> #define FUNC2(x,y) x##y #define FUNC1(x,y) FUNC2(x,y) #define FUNC(x) FUNC1(x,__COUNTER__) int FUNC(my_unique_prefix); int FUNC(my_unique_prefix); int main() { my_unique_prefix0 = 0; printf_s("/n%d",my_unique_prefix0); my_unique_prefix0++; printf_s("/n%d",my_unique_prefix0); } |
__cplusplus |
Defined for C++ programs only. |
_CPPLIB_VER |
Defined if you include any of the C++ Standard Library headers; reports which version of the Dinkumware header files are present. |
_CPPRTTI |
Defined for code compiled with /GR (Enable Run-Time Type Information). |
_CPPUNWIND |
Defined for code compiled with /GX (Enable Exception Handling). |
_DEBUG |
Defined when compiling with /LDd, /MDd, and /MTd. |
_DLL |
Defined when /MD or /MDd (Multithread DLL) is specified. |
__FUNCDNAME__ |
Valid only within a function and returns the decorated name of the enclosing function (as a string). __FUNCDNAME__ is not expanded if you use the /EP or /P compiler option. </ |