You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Microsoft Visual C++ compiler version consists of four fields:
12
+
13
+
M - major version (two digits)\
14
+
N - minor version (two digits)\
15
+
B - build version (five digits)\
16
+
R - revision version
17
+
18
+
Microsoft-specific compiler macros encode these fields as follows:
19
+
20
+
`_MSC_VER` = MMNN\
21
+
`_MSC_FULL_VER` = MMNNBBBBB\
22
+
`_MSC_BUILD` = R
23
+
24
+
For example, the compiler version for Visual Studio 2022 version 17.9.0 is 19.39.33519:
25
+
- The major version is 19
26
+
- The minor version is 39
27
+
- The build version is 33519
28
+
- The revision version is 0
29
+
30
+
The macros reflect these values like this:
31
+
-`_MSC_VER = 1939`
32
+
-`_MSC_FULL_VER = 193933519`
33
+
-`_MSC_BUILD` (the revision) is 0.
34
+
35
+
>[!Note]
36
+
>Visual Studio 2019 16.8 and 16.9 share the same major and minor versions, and so have the same value for `_MSC_VER`. As do Visual Studio 2019 16.10 and 16.11. To distinguish them, use `_MSC_FULL_VER` as described in [Service releases starting with Visual Studio 2017](#service-releases-starting-with-visual-studio-2017).
37
+
38
+
## A brief history of Visual C++ compiler versioning
39
+
40
+
### Visual Studio 6.0 through Visual Studio 2015 (14.0)
41
+
42
+
- For major releases, `_MSC_VER` increases by 100. `_MSC_FULL_VER` increases by 10,000,000.
43
+
- For minor releases, `_MSC_VER` increases by 10. `_MSC_FULL_VER` increases by 1,000,000.
44
+
45
+
>[!Note]
46
+
> Visual Studio .NET 2003 was considered a minor release.
47
+
48
+
### Visual Studio 2017 and later
49
+
50
+
- For major releases, the minor version increases by 10.
51
+
- For minor releases, the minor version increases by 1 starting with Visual Studio 2017 version 15.3.
52
+
53
+
### Service releases starting with Visual Studio 2017
54
+
55
+
Servicing releases can be distinguished by `_MSC_FULL_VER`. The build field (the BBBBB in the MMNNBBBBB version number) typically increases by 1.
56
+
57
+
For example, two cases where `_MSC_FULL_VER` is useful is to distinguish Visual Studio 2019 16.8 from 16.9, and Visual Studio 2019 16.10 from 16.11. That's because those versions share the same major and minor versions, and so have the same value for `_MSC_VER`.
58
+
59
+
To distinguish these versions, use `_MSC_FULL_VER`.\
60
+
The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.8 is 192829333.\
61
+
The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.9 is 192829910.
62
+
63
+
## Version macros
64
+
65
+
Recall that the version number consists of four fields:
66
+
67
+
M - major version (two digits)\
68
+
N - minor version (two digits)\
69
+
B - build version (five digits)\
70
+
R - revision version
71
+
72
+
**[`_MSC_VER`](../preprocessor/predefined-macros.md)** distinguishes between major and minor releases. It has the form: MMNN.
73
+
74
+
**[`_MSC_FULL_VER`](../preprocessor/predefined-macros.md)** represents the major, minor, and build version of the compiler. It has the form: MMNNBBBBB. Use it to distinguish between different versions of the compiler, including servicing releases. See [Service releases starting with Visual Studio 2017](#service-releases-starting-with-visual-studio-2017) for more information about Visual Studio 2019 16.8, 16.9, 16.10 and 16.11.
75
+
76
+
**[`_MSC_BUILD`](../preprocessor/predefined-macros.md)** represents the build version of the compiler. It has the form: R. Use it to distinguish between servicing releases.
77
+
78
+
When the major version changed between Visual Studio 2013 and Visual Studio 2015, `_MSC_VER` reflected the change by going from 1800 to 1900.
79
+
80
+
An example of a minor change is from Visual Studio 2022 17.1 to Visual Studio 2022 17.2. In that case, `_MSC_VER` changed from 1931 to 1932.
81
+
82
+
The following table lists the Visual C++ compiler `_MSC_VER` for each Visual Studio release:
83
+
84
+
| Visual Studio version |`_MSC_VER`|
85
+
|--|--|
86
+
| Visual Studio 6.0 | 1200 |
87
+
| Visual Studio .NET 2002 (7.0) | 1300 |
88
+
| Visual Studio .NET 2003 (7.1) | 1310 |
89
+
| Visual Studio 2005 (8.0) | 1400 |
90
+
| Visual Studio 2008 (9.0) | 1500 |
91
+
| Visual Studio 2010 (10.0) | 1600 |
92
+
| Visual Studio 2012 (11.0) | 1700 |
93
+
| Visual Studio 2013 (12.0) | 1800 |
94
+
| Visual Studio 2015 (14.0) | 1900 |
95
+
| Visual Studio 2017 RTW (15.0) | 1910 |
96
+
| Visual Studio 2017 version 15.3 | 1911 |
97
+
| Visual Studio 2017 version 15.5 | 1912 |
98
+
| Visual Studio 2017 version 15.6 | 1913 |
99
+
| Visual Studio 2017 version 15.7 | 1914 |
100
+
| Visual Studio 2017 version 15.8 | 1915 |
101
+
| Visual Studio 2017 version 15.9 | 1916 |
102
+
| Visual Studio 2019 RTW 16.0 | 1920 |
103
+
| Visual Studio 2019 version 16.1 | 1921 |
104
+
| Visual Studio 2019 version 16.2 | 1922 |
105
+
| Visual Studio 2019 version 16.3 | 1923 |
106
+
| Visual Studio 2019 version 16.4 | 1924 |
107
+
| Visual Studio 2019 version 16.5 | 1925 |
108
+
| Visual Studio 2019 version 16.6 | 1926 |
109
+
| Visual Studio 2019 version 16.7 | 1927 |
110
+
| Visual Studio 2019 version 16.8, 16.9 <sup>a</sup> | 1928 |
111
+
| Visual Studio 2019 version 16.10, 16.11 <sup>b</sup> | 1929 |
112
+
| Visual Studio 2022 RTW 17.0 | 1930 |
113
+
| Visual Studio 2022 version 17.1 | 1931 |
114
+
| Visual Studio 2022 version 17.2 | 1932 |
115
+
| Visual Studio 2022 version 17.3 | 1933 |
116
+
| Visual Studio 2022 version 17.4 | 1934 |
117
+
| Visual Studio 2022 version 17.5 | 1935 |
118
+
| Visual Studio 2022 version 17.6 | 1936 |
119
+
| Visual Studio 2022 version 17.7 | 1937 |
120
+
| Visual Studio 2022 version 17.8 | 1938 |
121
+
| Visual Studio 2022 version 17.9 | 1939 |
122
+
| Visual Studio 2022 version 17.10 | 1940 |
123
+
124
+
<sup>a</sup> Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and so have the same value for `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.8 is 192829333. The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.9 is 192829910.
125
+
126
+
<sup>b</sup> Visual Studio 2019 16.10 and 16.11 share the same major and minor versions (and so have the same value for `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.10 is 192929917. The minimum value of `_MSC_FULL_VER` for Visual Studio 2019 16.11 is 192930129.
The Microsoft C/C++ compiler (MSVC) predefines certain preprocessor macros, depending on the language (C or C++), the compilation target, and the chosen compiler options.
13
+
The Microsoft C/C++ compiler (MSVC) predefines certain preprocessor macros depending on the language (C or C++), the compilation target, and the chosen compiler options.
14
14
15
-
MSVC supports the predefined preprocessor macros required by the ANSI/ISO C99, C11, and C17 standards, and the ISO C++14, C++17, and C++20 standards. The implementation also supports several more Microsoft-specific preprocessor macros. Some macros are defined only for specific build environments or compiler options. Except where noted, the macros are defined throughout a translation unit as if they were specified as **`/D`** compiler option arguments. When defined, the macros are expanded to the specified values by the preprocessor before compilation. The predefined macros take no arguments and can't be redefined.
15
+
MSVC supports the predefined preprocessor macros required by the ANSI/ISO C99, C11, and C17 standards, and the ISO C++14, C++17, and C++20 standards. The implementation also supports several more Microsoft-specific preprocessor macros.
16
+
17
+
Some macros are defined only for specific build environments or compiler options. Except where noted, the macros are defined throughout a translation unit as if they were specified as **`/D`** compiler option arguments. When defined, the preprocessor expands macros their specified values before compilation. The predefined macros take no arguments and can't be redefined.
16
18
17
19
## Standard predefined identifier
18
20
@@ -36,9 +38,9 @@ The compiler supports these predefined macros specified by the ISO C99, C11, C17
36
38
37
39
-`__FILE__` The name of the current source file. `__FILE__` expands to a character string literal. To ensure that the full path to the file is displayed, use [**`/FC`** (Full Path of Source Code File in Diagnostics)](../build/reference/fc-full-path-of-source-code-file-in-diagnostics.md). This macro is always defined.
38
40
39
-
-`__LINE__` Defined as the integer line number in the current source file. The value of the `__LINE__` macro can be changed by using a `#line` directive. The integral type of the value of `__LINE__` can vary depending on context. This macro is always defined.
41
+
-`__LINE__` Defined as the integer line number in the current source file. The value of this macro can be changed by using a `#line` directive. The integral type of the value of `__LINE__` can vary depending on context. This macro is always defined.
40
42
41
-
-`__STDC__` Defined as 1 when compiled as C and if the [`/Za`](../build/reference/za-ze-disable-language-extensions.md) compiler option is specified. Starting in Visual Studio 2022 version 17.2, it's also defined as 1 when compiled as C and if the [`/std:c11`](../build/reference/std-specify-language-standard-version.md) or [`/std:c17`](../build/reference/std-specify-language-standard-version.md) compiler option is specified. Otherwise, undefined.
43
+
-`__STDC__` Defined as 1 when compiled as C and if the [`/Za`](../build/reference/za-ze-disable-language-extensions.md) compiler option is specified. Starting in Visual Studio 2022 version 17.2, it's defined as 1 when compiled as C and if the [`/std:c11`](../build/reference/std-specify-language-standard-version.md) or [`/std:c17`](../build/reference/std-specify-language-standard-version.md) compiler option is specified. Otherwise, undefined.
42
44
43
45
-`__STDC_HOSTED__` Defined as 1 if the implementation is a *hosted implementation*, one that supports the entire required standard library. Otherwise, defined as 0.
44
46
@@ -60,7 +62,7 @@ The compiler supports these predefined macros specified by the ISO C99, C11, C17
60
62
61
63
## Microsoft-specific predefined macros
62
64
63
-
MSVC supports these additional predefined macros.
65
+
MSVC supports other predefined macros:
64
66
65
67
-`__ATOM__` Defined as 1 when the [`/favor:ATOM`](../build/reference/favor-optimize-for-architecture-specifics.md) compiler option is set and the compiler target is x86 or x64. Otherwise, undefined.
66
68
@@ -238,50 +240,17 @@ MSVC supports these additional predefined macros.
238
240
239
241
- `_MANAGED` Defined as 1 when the [`/clr`](../build/reference/clr-common-language-runtime-compilation.md) compiler option is set. Otherwise, undefined.
240
242
241
-
- `_MSC_BUILD` Defined as an integer literal that contains the revision number element of the compiler's version number. The revision number is the fourth element of the period-delimited version number. For example, if the version number of the Microsoft C/C++ compiler is 15.00.20706.01, the `_MSC_BUILD` macro evaluates to 1. This macro is always defined.
243
+
- `_MSC_BUILD` Defined as an integer literal that contains the revision number element of the compiler's version number. The revision number is the last element of the period-delimited version number. For example, if the version number of the Microsoft C/C++ compiler is 15.00.20706.01, the `_MSC_BUILD` macro is 1. This macro is always defined.
242
244
243
245
- `_MSC_EXTENSIONS` Defined as 1 if the on-by-default [**`/Ze`** (Enable Language Extensions)](../build/reference/za-ze-disable-language-extensions.md) compiler option is set. Otherwise, undefined.
244
246
245
-
- `_MSC_FULL_VER` Defined as an integer literal that encodes the major, minor, and build number elements of the compiler's version number. The major number is the first element of the period-delimited version number, the minor number is the second element, and the build number is the third element. For example, if the version number of the Microsoft C/C++ compiler is 15.00.20706.01, the `_MSC_FULL_VER` macro evaluates to 150020706. Enter `cl /?` at the command line to view the compiler's version number. This macro is always defined.
246
-
247
-
- `_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 Microsoft C/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.
248
-
249
-
| Visual Studio version | `_MSC_VER` |
250
-
|--|--|
251
-
| Visual Studio 6.0 | 1200 |
252
-
| Visual Studio .NET 2002 (7.0) | 1300 |
253
-
| Visual Studio .NET 2003 (7.1) | 1310 |
254
-
| Visual Studio 2005 (8.0) | 1400 |
255
-
| Visual Studio 2008 (9.0) | 1500 |
256
-
| Visual Studio 2010 (10.0) | 1600 |
257
-
| Visual Studio 2012 (11.0) | 1700 |
258
-
| Visual Studio 2013 (12.0) | 1800 |
259
-
| Visual Studio 2015 (14.0) | 1900 |
260
-
| Visual Studio 2017 RTW (15.0) | 1910 |
261
-
| Visual Studio 2017 version 15.3 | 1911 |
262
-
| Visual Studio 2017 version 15.5 | 1912 |
263
-
| Visual Studio 2017 version 15.6 | 1913 |
264
-
| Visual Studio 2017 version 15.7 | 1914 |
265
-
| Visual Studio 2017 version 15.8 | 1915 |
266
-
| Visual Studio 2017 version 15.9 | 1916 |
267
-
| Visual Studio 2019 RTW (16.0) | 1920 |
268
-
| Visual Studio 2019 version 16.1 | 1921 |
269
-
| Visual Studio 2019 version 16.2 | 1922 |
270
-
| Visual Studio 2019 version 16.3 | 1923 |
271
-
| Visual Studio 2019 version 16.4 | 1924 |
272
-
| Visual Studio 2019 version 16.5 | 1925 |
273
-
| Visual Studio 2019 version 16.6 | 1926 |
274
-
| Visual Studio 2019 version 16.7 | 1927 |
275
-
| Visual Studio 2019 version 16.8, 16.9 | 1928 |
276
-
| Visual Studio 2019 version 16.10, 16.11 | 1929 |
277
-
| Visual Studio 2022 RTW (17.0) | 1930 |
278
-
| Visual Studio 2022 version 17.1 | 1931 |
279
-
| Visual Studio 2022 version 17.2 | 1932 |
280
-
| Visual Studio 2022 version 17.3 | 1933 |
281
-
| Visual Studio 2022 version 17.4 | 1934 |
282
-
| Visual Studio 2022 version 17.5 | 1935 |
283
-
284
-
To test for compiler releases or updates in a given version of Visual Studio or after, use the `>=` operator. You can use it in a conditional directive to compare `_MSC_VER` against that known version. If you have several mutually exclusive versions to compare, order your comparisons in descending order of version number. For example, this code checks for compilers released in Visual Studio 2017 and later. Next, it checks for compilers released in or after Visual Studio 2015. Then it checks for all compilers released before Visual Studio 2015:
247
+
- `_MSC_FULL_VER` Defined as an integer literal that encodes the major, minor, and build number elements of the compiler's version number. The major number is the first element of the period-delimited version number, the minor number is the second element, and the build number is the third element.
248
+
249
+
For example, if the Microsoft C/C++ compiler version is 19.39.33519, `_MSC_FULL_VER` is 193933519. Enter `cl /?` at the command line to view the compiler's version number. This macro is always defined. For more information about compiler versioning, see [C++ compiler versioning](../overview/compiler-versions.md) and specifically [Service releases starting with Visual Studio 2017](../overview/compiler-versions.md#service-releases-starting-with-visual-studio-2017) for more information about Visual Studio 2019 16.8, 16.9, 16.10 and 16.11, which require `_MSC_FULL_VER` to tell them apart.
250
+
251
+
- `_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 Microsoft C/C++ compiler is 17.00.51106.1, the value of `_MSC_VER` is 1700. Enter `cl /?` at the command line to view the compiler's version number. This macro is always defined.
252
+
253
+
To test for compiler releases or updates in a given version of Visual Studio or later, use the `>=` operator. You can use it in a conditional directive to compare `_MSC_VER` against that known version. If you have several mutually exclusive versions to compare, order your comparisons in descending order of version number. For example, this code checks for compilers released in Visual Studio 2017 and later. Next, it checks for compilers released in or after Visual Studio 2015. Then it checks for all compilers released before Visual Studio 2015:
285
254
286
255
```cpp
287
256
#if _MSC_VER >= 1910
@@ -293,9 +262,9 @@ MSVC supports these additional predefined macros.
293
262
#endif
294
263
```
295
264
296
-
To test for compiler versions that share major and minor numbers, use the major, minor, and build numbers in `_MSC_FULL_VER` for comparisons. The compilers in Visual Studio 2019 version 16.9 have an `_MSC_FULL_VER` value of 192829500 or greater. The compilers in Visual Studio 2019 version 16.11 have an `_MSC_FULL_VER` value of 192930100 or greater.
265
+
For more information about Visual Studio 2019 16.8 and 16.9, and 16.10 and 16.11, which share the same major and minor versions (and so have the same value for `_MSC_VER`), see [Service releases starting with Visual Studio 2017](../overview/compiler-versions.md#service-releases-starting-with-visual-studio-2017).
297
266
298
-
For more information, see [Visual C++ Compiler Version](https://devblogs.microsoft.com/cppblog/visual-c-compiler-version/)in the Microsoft C++ Team Blog.
267
+
For more information about the history of compiler versioning, and compiler version numbers and the Visual Studio versions they correspond to, see [C++ compiler versioning](../overview/compiler-versions.md). Also, [Visual C++ Compiler Version](https://devblogs.microsoft.com/cppblog/visual-c-compiler-version/)on the Microsoft C++ team blog.
299
268
300
269
-`_MSVC_LANG` Defined as an integer literal that specifies the C++ language standard targeted by the compiler. It's set only in code compiled as C++. The macro is the integer literal value `201402L` by default, or when the [`/std:c++14`](../build/reference/std-specify-language-standard-version.md) compiler option is specified. The macro is set to `201703L` if the [`/std:c++17`](../build/reference/std-specify-language-standard-version.md) compiler option is specified. The macro is set to `202002L` if the [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) compiler option is specified. It's set to a higher, unspecified value when the [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) option is specified. 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.
301
270
@@ -346,9 +315,9 @@ MSVC supports these additional predefined macros.
346
315
347
316
No preprocessor macros that identify the ATL or MFC library version are predefined by the compiler. ATL and MFC library headers define these version macros internally. They're undefined in preprocessor directives made before the required header is included.
348
317
349
-
- `_ATL_VER` Defined in \<atldef.h> as an integer literal that encodes the ATL version number.
318
+
- `_ATL_VER` Defined in `<atldef.h>` as an integer literal that encodes the ATL version number.
350
319
351
-
- `_MFC_VER` Defined in \<afxver_.h> as an integer literal that encodes the MFC version number.
320
+
- `_MFC_VER` Defined in `<afxver_.h>` as an integer literal that encodes the MFC version number.
0 commit comments