VC ++ predefined macro)

Source: Internet
Author: User
Tags month name microsoft c

In order to facilitate your query, I Will repost a copy from msdn here.

From: msdn.microsoft.com/en-us/library/b0084kay (vs.80). aspx

C/C ++ Preprocessor reference

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.

ANSI-compliant predefined macros
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 nameMmmIs the same as for dates generated by the Library Function
AsctimeDeclared 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_ File __As follows:

#include <stdio.h>#define WIDEN2(x) L ## x#define WIDEN(x) WIDEN2(x)#define __WFILE__ WIDEN(__FILE__)wchar_t *pwsz = __WFILE__;int main() {}

_ Line __

The line number in the current source file. The line number is a decimal integer constant. It can be altered with
# LineDirective.

_ Stdc __

Indicates full conformance with the ansi c standard. defined as the integer constant 1 only if
/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, WhereDddIs the abbreviated day of the week and
DateIs an integer from 1 to 31.

Microsoft-specific predefined macros
Macro Description

_ Atl_ver

Defines the ATL version.

_ Char_unsigned

DefaultCharType 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.

// clr_ver.cpp// compile with: /clrusing namespace System;int main() {   Console::WriteLine(__CLR_VER);}

_ Cplusplus_cli

Defined when compiling/CLR,/CLR: pure, Or
/CLR: safe. Value of _ cplusplus_cli is 200406. _ cplusplus_cli is in effect throughout the Translation Unit.

// cplusplus_cli.cpp// compile with: /clr#include "stdio.h"int main() {   #ifdef __cplusplus_cli      printf("%d\n", __cplusplus_cli);   #else      printf("not defined\n");   #endif}

_ 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
/GR (enable run-time type information ).

_ Cppunwind

Defined for Code Compiled
/GX (enable Exception Handling ).

_ Debug

Defined when compiling
/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
/EP or
/P compiler option.

_ Funcsig __

Valid only within a function and returns the signature of the enclosing function (as a string ).
_ Funcsig __Is not expanded if you use
/EP or
/P compiler option.

On a 64-bit operating system, the calling convention is_ CdeclBy default.

_ Function __

Valid only within a function and returns the undecorated name of the enclosing function (as a string ).
_ Function __Is not expanded if you use
/EP or
/P compiler option.

_ Integral_max_bits

Reports the maximum size (in bits) for an integral type.

// integral_max_bits.cpp#include <stdio.h>int main() {   printf("%d\n", _INTEGRAL_MAX_BITS);}

_ M_alpha

Defined for DEC Alpha platforms (no longer supported ).

_ M_cee

Defined for a compilation that uses any form/CLR(/CLR: oldsyntax,
/CLR: safe, For example ).

_ M_cee_pure

Defined for a compilation that uses/CLR: pure.

_ M_cee_safe

Defined for a compilation that uses/CLR: safe.

_ M_ix86

Defined for x86 processors. See
Values for _ m_ix86 for more details.

_ M_ia64

Defined for itanium Processor family 64-bit processors.

_ M_ix86_fp

Expands to a value indicating which/ArchCompiler option was used:

  • 0 if/ArchWas not used.

  • 1 If/Arch: SSEWas used.

  • 2 If/Arch: sse2Was used.

  • See/arch (Minimum CPU architecture) for more information.

_ M_mppc

Defined for Power Macintosh platforms (no longer supported ).

_ M_mrx000

Defined for MIPS platforms (no longer supported ).

_ M_ppc

Defined for PowerPC platforms (no longer supported ).

_ M_x64

Defined for x64 processors.

_ Managed

Defined to be 1 when
/CLR is specified.

_ Mfc_ver

Defines the MFC version. For example, 0x0700 represents MFC version 7.

_ Msc_extensions

This macro is defined when compiling with
/Ze compiler option (the default). Its value, when defined, is 1.

_ Msc_ver

Reports the major and minor versions of the compiler. for example, 1310 for Microsoft Visual C ++. NET 2003. 1310 represents version 13 and a 1.0 point release. the Visual C ++ 2005 compiler version is 1400.

TypeCL /?At the command line to see the major and minor versions of your compiler along with the build number.

_ Msvc_runtime_checks

Defined when one of
/RTC compiler options is specified.

_ Mt

Defined when
/MD or/MDD (multithreaded DLL) or
/Mt or/MTD (multithreaded) is specified.

_ Native_wchar_t_defined

Defined when
/ZC: wchar_t is used.

_ OpenMP

Defined when compiling with/OpenMP, returns an integer representing the date of the OpenMP specification implemented by Visual C ++.

// _OPENMP_dir.cpp// compile with: /openmp #include <stdio.h> int main() {   printf("%d\n", _OPENMP);}

_ Vc_nodefaultlib

Defined when/ZLIs used; see/ZL (omit default library name) for more information.

_ Wchar_t_defined

Defined when
/ZC: wchar_t is used or if wchar_t is defined in a system header file encoded in your project.

_ Win32

Defined for applications for Win32 and win64. always defined.

_ Win64

Defined for applications for win64.

_ Wp64

Defined when specifying
/Wp64.

As shown in following table, the compiler generates a value for the Preprocessor identifiers that reflect the processor option specified.

Values for _ m_ix86
Option in Development Environment Command-line option Resulting value

Blend

/GB

_ M_ix86 = 600(Default. Future compilers will emit a different value to reflect the dominant processor .)

Pentium

/G5

_ M_ix86 = 500

Pentium Pro, Pentium II, and Pentium III

/G6

_ M_ix86 = 600

80386

/G3

_ M_ix86 = 300

80486

/G4

_ M_ix86 = 400

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.