Predefined Macros

-- VC++ 2009. 10. 1. 13:52
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
The compiler recognizes seven predefined ANSI C macros (see Table 1.1), and the Microsoft C++ implementation provides several more (see Table 1.2). These macros take no arguments and cannot be redefined. Their value (except for __LINE__ and __FILE__) must be constant throughout compilation. Some of the predefined macros listed below are defined with multiple values. Their values can be set by selecting the corresponding menu option in the Visual C++ development environment, or by using a command-line switch. See the tables below for more information.

Table 1.1   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 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.

__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 options.

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

 

Table 1.2   Microsoft-Specific Predefined Macros

Macro

Description

_CHAR_UNSIGNED

Default char type is unsigned. Defined when /J is specified.

__cplusplus

Defined for C++ programs only.

_CPPRTTI

Defined for code compiled with /GR (Enable Run-Time Type Information).

_CPPUNWIND

Defined for code compiled with /GX (Enable Exception Handling).

_DLL

Defined when /MD or /MDd (Multithread DLL) is specified.

_M_ALPHA

Defined for DEC ALPHA platforms. It is defined as 1 by the ALPHA compiler, and it is not defined if another compiler is used.

_M_IX86

Defined for x86 processors. See Table 1.3 for more details.

_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).

_MFC_VER

Defines the MFC version. Defined as 0x0600 for Microsoft Foundation Class Library 6.0 or later. Always defined.

_MSC_EXTENSIONS

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

_MSC_VER

Defines the compiler version. Defined as 1200 for Microsoft Visual C++ 6.0 or later. Always defined.

_MT

Defined when /MD or /MDd (Multithreaded DLL) or /MT or /MTd (Multithreaded) is specified.

_WIN32

Defined for applications for Win32®. Always defined.

 

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

Table 1.3   Values for _M_IX86

Option in Development Environment

Command-Line Option

Resulting Value

Blend

/GB

_M_IX86 = 500 (Default. Future compilers will emit a different value to reflect the dominant processor.)

Pentium

/G5

_M_IX86 = 500

Pentium Pro

/G6

_M_IX86 = 600

80386

/G3

_M_IX86 = 300

80486

/G4

_M_IX86 = 400

 
출처 : http://msdn.microsoft.com/en-us/library/ms880173.aspx

BONUS

_WIN32_WINNT, WINVER 값

Windows "Longhorn"         0x0600 <= 이게 비스타인듯~
Windows Server 2003         0x0502
Windows XP                     0x0501
Windows 2000                   0x0500
Windows 98                      0x0410
Windows 95                      0x0400


_WIN32_IE 값

IE 7.0                       0x0700
IE 6.0 SP2                0x0603
IE 6.0 SP1                0x0601
IE 6.0                       0x0600
IE 5.5                       0x0550
IE 5.01                     0x0501
IE 5.0  5.0a  5.0b       0x0500
IE 4.01                     0x0401
IE 4.0                       0x0400
IE 3.0  3.01  3.02        0x0300

ANSI 호환 매크로들

__DATE__ 매크로가 사용된 파일이 컴파일 된 시간
__FILE__ 매크로가 사용된 파일의 이름
__LINE__ 매크로가 사용된 파일에서 매크로가 있는 곳의 라인 넘버
__STDC__ ANSI C 표준에 준하는지 확인. /Za옵션이 없거나 C++코드 컴파일 하면 정의 안됨
__TIME__ 매크로가 사용된 파일의 가장 최근에 컴파일 된 시간
__TIMESTAMP__ 매크로가 사용된 파일의 최종 수정된 시간

Microsoft 에서만 사용되는 매크로들

_ATL_VER ATL 버전
_CHAR_UNSIGNED char타입을 unsigned로 함. /J 옵션 주면 정의 됨
__CLR_VER Common Language Runtime 버전
__cplusplus_cli /clr, /clr:pure, /clr:safe 옵션 주면 정의.
__COUNTER__ 빌드 할때마다 1씩 증가하는 매크로. PCH에 저장됨.
__cplusplus C++사용할 때 정의 됨
_CPPLIB_VER C++ 표준 라이브러리 버전
_CPPRTTI RTTI 사용하면 정의 됨
_CPPUNWIND 예외 처리 사용하면 정의 됨
_DEBUG 디버그 모드 (/LDd, /MDd, /MTd 옵션 주면 됨)
_DLL 다중 쓰레드 버전의 DLL(/MD, /MDd 옵션)사용할 때 정의
__FUNCDNAME__ 매크로가 사용된 함수의 decorated name (/EP나 /P옵션이 없어야 함)
__FUNCSIG__ 매크로가 사용된 함수의 signature (/EP나 /P옵션이 없어야 함)
__FUNCTION__ 매크로가 사용된 함수의 이름 (/EP나 /P옵션이 없어야 함)

아~ 귀찮어, 졸려, 담배 땡겨, 배불러, 안해. 나머진 MSDN의 Predefined Macros 항목에서 찾아보슈.

_INTEGRAL_MAX_BITS

_M_ALPHA
_M_CEE
_M_CEE_PURE
_M_CEE_SAFE
_M_IX86
_M_IA64
_M_IX86_FP
_M_MPPC
_M_MRX00
_M_PPC
_M_X64
_MANAGED
_MFC_VER
_MSC_EXTENSIONS
_MSC_VER
__MSVC_RUNTIME_CHECKS
_MT
_NATIVE_WCHAR_T_DEFINED
_OPENMP
_VC_NODEFAULTLIB
_WCHAR_T_DEFINED
_WIN32
_WIN64
_Wp64

출처 : http://duckii.egloos.com/692512

posted by 어린왕자악꿍