The main predefined values of the compiler and Windows operating system affect program compilation. The following is a basic list.
(For details about the pre-Definition of C ++ compilation, search "predefined macros" in msdn for a more comprehensive description)
I. c ++ pre-defined
_ Cplusplus
It is generally used in the header file of the C library. The method is as follows:
# Ifdef _ cplusplus
Extern "C "{
# Endif
... // C library function and data type declaration
# Ifdef _ cplusplus
}
# Endif
II. C ++ compiler version Definition
The C ++ here refers to the definition of the CL version of The vs (Visual Studio, VC ++) compiler. It can also be said that it is the pre-defined version of vs IDE. (help search, vs2005, vs2008)
Version pre-defined: _ msc_ver
Compiler _ msc_ver Value
----------------------
C compiler version 6.0 600
C/C ++ compiler version 7.0 700
Visual c ++, windows, version 1.0 800
Visual c ++, 32-bit, version 1.0 800
Visual c ++, windows, version 2.0 900
Visual c ++, 32-bit, version 2.x 900
Visual c ++, 32-bit, version 4.0 1000
Visual c ++, 32-bit, version 5.0 1100
Visual c ++, 32-bit, version 6.0 1200
Visual c ++, Version 2003. Net 1310
Visual c ++, Version 2005 1400
Visual c ++, version 2008 1500
Iii. File compilation options
3.1 pre-defined compilation date:__ Date __
Indicates the compilation date of the current file. The result is a string in the format:Mmm dd yyyy, Where the month nameMmmIn time. hAsctime ()Name of the month in the date generated by the function
Compilation Time:_ Time __
The result is a string in the format:Hh: mm: SS
Last modification time definition:_ Timestamp __
Format:Ddd Mmm date hh: mm: SS yyyy, Where the day is 1 ~ 31
3.2 File Name Pre-definition:_ File __
This file name can be printed at the output position of the file, which is useful in writing exception debugging logs.
File row number pre-defined:_ Line __
The row number of the current Code. It is an integer.
Iv. Windows Version Problems
(Note: the translation in this section is based on my understanding of these English terms and may be inaccurate)
There are two methods to define these versions. One is the old predefinition and the other is the new one.
The new predefinition (The following table describes the preferred Macros in use by the Windows header files .):
Minimum system required |
Macros to define |
Windows Server 2008 |
Ntddi_version> = ntddi_longhorn |
Windows Vista |
Ntddi_version> = ntddi_vista |
Windows Server 2003 SP1 |
Ntddi_version> = ntddi_ws03sp1 |
Windows Server 2003 |
Ntddi_version> = ntddi_ws03 |
Windows XP SP2 |
Ntddi_version> = ntddi_winxpsp2 |
Windows XP SP1 |
Ntddi_version> = ntddi_winxpsp1 |
Windows XP |
Ntddi_version> = ntddi_winxp |
Windows 2000 SP4 |
Ntddi_version> = ntddi_win2ksp4 |
Windows 2000 sp3 |
Ntddi_version> = ntddi_win2ksp3 |
Windows 2000 sp2 |
Ntddi_version> = ntddi_win2ksp2 |
Windows 2000 sp1 |
Ntddi_version> = ntddi_win2ksp1 |
Windows 2000 |
Ntddi_version> = ntddi_win2k |
The following table describes the legacy Macros in use by the Windows header files .):
Minimum system required |
Macros to define |
Windows Server 2008 |
_ Win32_winnt> = 0x0600, winver> = 0x0600 |
Windows Vista |
_ Win32_winnt> = 0x0600, winver> = 0x0600 |
Windows Server 2003 |
_ Win32_winnt> = 0x0502, winver> = 0x0502 |
Windows XP |
_ Win32_winnt> = 0x0501, winver> = 0x0501 |
Windows 2000 |
_ Win32_winnt> = 0x0500, winver> = 0x0500 |
Windows NT 4.0 |
_ Win32_winnt> = 0x0400, winver> = 0x0400 |
Windows ME |
_ Win32_windows = 0x0500, winver> = 0x0500 |
Windows 98 |
_ Win32_windows> = 0x0410, winver> = 0x0410 |
Windows 95 |
_ Win32_windows> = 0x0400, winver> = 0x0400 |
Internet Explorer 7.0 |
_ Win32_ie> = 0x0700 |
Internet Explorer 6.0 SP2 |
_ Win32_ie> = 0x0603 |
Internet Explorer 6.0 SP1 |
_ Win32_ie> = 0x0601 |
Internet Explorer 6.0 |
_ Win32_ie> = 0x0600 |
Internet Explorer 5.5 |
_ Win32_ie> = 0x0550 |
Internet Explorer 5.01 |
_ Win32_ie> = 0x0501 |
Internet Explorer 5.0, 5.0a, 5.0b |
_ Win32_ie> = 0x0500 |
Internet Explorer 4.01 |
_ Win32_ie> = 0x0401 |
Internet Explorer 4.0 |
_ Win32_ie> = 0x0400 |
Internet Explorer 3.0, 3.01, 3.02 |
_ Win32_ie> = 0x0300 |
(This article may be updated later)