|
1 | 1 | ---
|
2 | 2 | title: "Predefined Macros | Microsoft Docs"
|
3 |
| -ms.custom: "" |
4 |
| -ms.date: "11/16/2017" |
5 |
| -ms.reviewer: "" |
6 |
| -ms.suite: "" |
| 3 | +ms.custom: "update_every_version" |
| 4 | +ms.date: "04/30/2018" |
7 | 5 | ms.technology: ["cpp-tools"]
|
8 |
| -ms.tgt_pltfrm: "" |
9 | 6 | ms.topic: "reference"
|
10 | 7 | f1_keywords: ["_ATL_VER", "__ATOM__", "__AVX__", "__AVX2__", "_CHAR_UNSIGNED", "__CLR_VER", "_CONTROL_FLOW_GUARD", "__COUNTER__", "__cplusplus", "__cplusplus_cli", "__cplusplus_winrt", "_CPPRTTI", "_CPPUNWIND", "__DATE__", "_DEBUG", "_DLL", "__FILE__", "__FUNCDNAME__", "__FUNCSIG__", "__FUNCTION__", "_INTEGRAL_MAX_BITS", "_ISO_VOLATILE", "_KERNEL_MODE", "__LINE__", "_M_AMD64", "_M_ARM", "_M_ARM_ARMV7VE", "_M_ARM_FP", "_M_ARM64", "_M_CEE", "_M_CEE_PURE", "_M_CEE_SAFE", "_M_FP_EXCEPT", "_M_FP_FAST", "_M_FP_PRECISE", "_M_FP_STRICT", "_M_IX86", "_M_IX86_FP", "_M_X64", "_MANAGED", "_MFC_VER", "_MSC_BUILD", "_MSC_EXTENSIONS", "_MSC_FULL_VER", "_MSC_VER", "_MSVC_LANG", "__MSVC_RUNTIME_CHECKS", "_MT", "_NATIVE_WCHAR_T_DEFINED", "_NO_SIZED_DEALLOCATION", "_OPENMP", "_PREFAST_", "_RESUMABLE_FUNCTIONS_SUPPORTED", "_RTC_CONVERSION_CHECKS_ENABLED", "__STDC__", "__STDC_HOSTED__", "__STDCPP_THREADS__", "__TIME__", "__TIMESTAMP__", "__VA_ARGS__", "_VC_NODEFAULTLIB", "_WCHAR_T_DEFINED", "_WIN32", "_WIN64", "_WINRT_DLL", "__func__"]
|
11 | 8 | dev_langs: ["C++"]
|
12 | 9 | helpviewer_keywords: ["timestamps, preprocessor macro", "cl.exe compiler, version number", "version numbers, C/C++ compiler (cl.exe)", "macros, predefined C++", "preprocessor, macros", "predefined macros", "_ATL_VER macro", "__ATOM__ macro", "__AVX__ macro", "__AVX2__ macro", "_CHAR_UNSIGNED macro", "__CLR_VER macro", "_CONTROL_FLOW_GUARD macro", "__COUNTER__ macro", "__cplusplus macro", "__cplusplus_cli macro", "__cplusplus_winrt macro", "_CPPRTTI macro", "_CPPUNWIND macro", "__DATE__ macro", "_DEBUG macro", "_DLL macro", "__FILE__ macro", "__FUNCDNAME__ macro", "__FUNCSIG__ macro", "__FUNCTION__ macro", "_INTEGRAL_MAX_BITS macro", "_ISO_VOLATILE macro", "_KERNEL_MODE macro", "__LINE__ macro", "_M_AMD64 macro", "_M_ARM macro", "_M_ARM_ARMV7VE macro", "_M_ARM_FP macro", "_M_ARM64 macro", "_M_CEE macro", "_M_CEE_PURE macro", "_M_CEE_SAFE macro", "_M_FP_EXCEPT macro", "_M_FP_FAST macro", "_M_FP_PRECISE macro", "_M_FP_STRICT macro", "_M_IX86 macro", "_M_IX86_FP macro", "_M_X64 macro", "_MANAGED macro", "_MFC_VER macro", "_MSC_BUILD macro", "_MSC_EXTENSIONS macro", "_MSC_FULL_VER macro", "_MSC_VER macro", "_MSVC_LANG macro", "__MSVC_RUNTIME_CHECKS macro", "_MT macro", "_NATIVE_WCHAR_T_DEFINED macro", "_NO_SIZED_DEALLOCATION macro", "_OPENMP macro", "_PREFAST_ macro", "_RESUMABLE_FUNCTIONS_SUPPORTED macro", "_RTC_CONVERSION_CHECKS_ENABLED macro", "__STDC__ macro", "__STDC_HOSTED__ macro", "__STDCPP_THREADS__ macro", "__TIME__ macro", "__TIMESTAMP__ macro", "__VA_ARGS__ macro", "_VC_NODEFAULTLIB macro", "_WCHAR_T_DEFINED macro", "_WIN32 macro", "_WIN64 macro", "_WINRT_DLL macro", "__func__ identifier"]
|
13 | 10 | ms.assetid: 1cc5f70a-a225-469c-aed0-fe766238e23f
|
14 |
| -caps.latest.revision: 75 |
15 | 11 | author: "corob-msft"
|
16 | 12 | ms.author: "corob"
|
17 |
| -manager: "ghogen" |
18 | 13 | ms.workload: ["cplusplus"]
|
19 | 14 | ---
|
20 | 15 | # Predefined Macros
|
@@ -229,6 +224,37 @@ Microsoft Visual C++ supports these additional predefined macros.
|
229 | 224 |
|
230 | 225 | - **_MSC_VER** Defined as an integer literal that encodes the major and minor number elements of the compiler's version number. The major number is the first element of the period-delimited version number and the minor number is the second element. For example, if the version number of the Visual C++ compiler is 17.00.51106.1, the **_MSC_VER** macro evaluates to 1700. Enter **cl /?** at the command line to view the compiler's version number. This macro is always defined.
|
231 | 226 |
|
| 227 | + |Visual Studio version|_MSC_VER| |
| 228 | + |-|-| |
| 229 | + |Visual Studio 6.0|1200| |
| 230 | + |Visual Studio .NET 2002 (7.0)|1300| |
| 231 | + |Visual Studio .NET 2003 (7.1)|1310| |
| 232 | + |Visual Studio 2005 (8.0)|1400| |
| 233 | + |Visual Studio 2008 (9.0)|1500| |
| 234 | + |Visual Studio 2010 (10.0)|1600| |
| 235 | + |Visual Studio 2012 (11.0)|1700| |
| 236 | + |Visual Studio 2013 (12.0)|1800| |
| 237 | + |Visual Studio 2015 (14.0)|1900| |
| 238 | + |Visual Studio 2017 RTW (15.0)|1910| |
| 239 | + |Visual Studio 2017 version 15.3|1911| |
| 240 | + |Visual Studio 2017 version 15.5|1912| |
| 241 | + |Visual Studio 2017 version 15.6|1913| |
| 242 | + |Visual Studio 2017 version 15.7|1914| |
| 243 | +
|
| 244 | + To test for compiler releases or updates in a given version of Visual Studio or after, use the **>=** (greater-or-equal) operator to compare **_MSC_VER** against that known version. If you have several versions to compare in a mutually exclusive manner, we recommend you order your comparisons in decreasing order of version number. For example, this code checks for compilers released in Visual Studio 2015 and later, then compilers released in or after Visual Studio 2013, then takes an action for all compilers released before Visual Studio 2013: |
| 245 | +
|
| 246 | + ```cpp |
| 247 | + #if _MSC_VER >= 1900 |
| 248 | + // . . . |
| 249 | + #elif _MSC_VER >= 1800 |
| 250 | + // . . . |
| 251 | + #else |
| 252 | + // . . . |
| 253 | + #endif |
| 254 | + ``` |
| 255 | + |
| 256 | + For more information, see [Visual C++ Compiler Version](https://blogs.msdn.microsoft.com/vcblog/2016/10/05/visual-c-compiler-version/) in the Visual C++ Team Blog. |
| 257 | + |
232 | 258 | - **_MSVC_LANG** Defined as an integer literal that specifies the C++ language standard targeted by the compiler. When compiled as C++, the macro is the integer literal value 201402L if the [/std:c++14](../build/reference/std-specify-language-standard-version.md) compiler option is set, or by default; it is set to 201703L if the [/std:c++17](../build/reference/std-specify-language-standard-version.md) compiler option is set; and it is set to a higher, unspecified value when the [/std:c++latest](../build/reference/std-specify-language-standard-version.md). Otherwise, the macro is undefined. The **_MSVC_LANG** macro and [/std (Specify Language Standard Version)](../build/reference/std-specify-language-standard-version.md) compiler options are available beginning in Visual Studio 2015 Update 3.
|
233 | 259 |
|
234 | 260 | - **__MSVC_RUNTIME_CHECKS** Defined as 1 when one of the [/RTC](../build/reference/rtc-run-time-error-checks.md) compiler options is set. Otherwise, undefined.
|
|
0 commit comments