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. They are reflected in various Microsoft-specific compiler macros that can be used to distinguish which version of the compiler is compiling your code.
11
+
The Microsoft Visual C++ compiler version consists of four fields. They're reflected in various Microsoft-specific compiler macros that can be used to distinguish which version of the compiler is compiling your code.
12
12
13
13
The version number consists of four fields:
14
14
15
-
M - major version (2 digits)\
16
-
m - minor version (2 digits)\
17
-
B - build version (5 digits)\
15
+
M - major version (two digits)\
16
+
N - minor version (two digits)\
17
+
B - build version (five digits)\
18
18
R - revision version
19
19
20
20
Microsoft-specific compiler macros encode these fields as follows:
21
21
22
-
`_MSC_VER` = MMmm
23
-
`_MSC_FULL_VER` = MMmmBBBBB
24
-
`_MSC_BUILD` = R
22
+
`_MSC_VER = MMNN`
23
+
`_MSC_FULL_VER = MMNNBBBBB`
24
+
`_MSC_BUILD = R`
25
25
26
26
For example, for Visual Studio 2022 version 17.9.0, the compiler version is 19.39.33519. The major version is 19, the minor version is 39, the build version is 33519, and the revision version is 0. In other words, `_MSC_VER` is 1939, `_MSC_FULL_VER` is 193933519, and `_MSC_BUILD` (the revision) is 0.
27
27
28
-
Note: Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER` instead as described in [Service releases starting with Visual Studio 2017](#service-releases-starting-with-visual-studio-2017). The same is true for distinguishing Visual Studio 2019 16.10 and 16.11.
28
+
Note: Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER` instead as described in [Service releases starting with Visual Studio 2017](#service-releases-starting-with-visual-studio-2017). The same is true for distinguishing Visual Studio 2019 16.10 from 16.11.
29
29
30
30
How these fields change to distinguish between different versions of the compiler varies, as described in the following sections.
31
31
@@ -45,24 +45,27 @@ Note: Visual Studio .NET 2003 was considered a minor release.
45
45
46
46
### Service releases starting with Visual Studio 2017
47
47
48
-
- Servicing releases can be distinguished using `_MSC_FULL_VER`. The build field (the BBBBB in the MMmmBBBBB version number) typically increases by 1.
48
+
- Servicing releases can be distinguished using `_MSC_FULL_VER`. The build field (the BBBBB in the MMNNBBBBB version number) typically increases by 1.
49
49
50
-
For example, two cases where `_MSC_FULL_VER` is particularly useful is to distinguish between Visual Studio 2019 16.8 and 16.9, as well as Visual Studio 2019 16.10 and 16.11. The reason is that those versions share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`.
50
+
For example, two cases where `_MSC_FULL_VER` is useful is to distinguish between Visual Studio 2019 16.8 and 16.9, as well as Visual Studio 2019 16.10 and 16.11. The reason is that those versions share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`.
51
51
52
52
## Version macros
53
53
54
54
Recall that the version number consists of four fields:
55
55
56
-
M - major version (2 digits)\
57
-
m - minor version (2 digits)\
58
-
B - build version (4 digits)\
56
+
M - major version (two digits)\
57
+
N - minor version (two digits)\
58
+
B - build version (five digits)\
59
59
R - revision version
60
60
61
-
-[`_MSC_VER`](../preprocessor/predefined-macros.md) distinguishes between different versions of the compiler at a high level. It's used to distinguish between major and minor releases. `_MSC_VER` = MMmm.
62
-
-[`_MSC_FULL_VER`](../preprocessor/predefined-macros.md) represents the major, minor, and build version of the compiler. `_MSC_FULL_VER` = MMmmBBBBB. It's used to distinguish between different versions of the compiler, including servicing releases. Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The same is true for Visual Studio 2019 16.10 and 16.11.
63
-
-[`_MSC_BUILD`](../preprocessor/predefined-macros.md) represents the build version of the compiler. `_MSC_BUILD` = R.Use it to distinguish between servicing releases.
61
+
[`_MSC_VER`](../preprocessor/predefined-macros.md) distinguishes between different versions of the compiler at a high level. Use it to distinguish between major and minor releases. `_MSC_VER = MMNN`.
64
62
65
-
For example, the major version changed between Visual Studio 2013 and Visual Studio 2015, reflected by a change in `_MSC_VER` from 1800 to 1900. An example of a minor change is from Visual Studio 2022 17.1 to Visual Studio 2022 17.2, when `_MSC_VER` changed from 1931 to 1932.
63
+
[`_MSC_FULL_VER`](../preprocessor/predefined-macros.md) represents the major, minor, and build version of the compiler. `_MSC_FULL_VER = MMNNBBBBB`. Use it used to distinguish between different versions of the compiler, including servicing releases. Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The same is true for Visual Studio 2019 16.10 and 16.11.
64
+
65
+
[`_MSC_BUILD`](../preprocessor/predefined-macros.md) represents the build version of the compiler. `_MSC_BUILD` = R. Use it to distinguish between servicing releases.
66
+
67
+
For example, the major version changed between Visual Studio 2013 and Visual Studio 2015, reflected by a change in `_MSC_VER` from 1800 to 1900.\
68
+
An example of a minor change is from Visual Studio 2022 17.1 to Visual Studio 2022 17.2, when `_MSC_VER` changed from 1931 to 1932.
66
69
67
70
The following table lists the Visual C++ compiler `_MSC_VER` for each Visual Studio release:
68
71
@@ -106,11 +109,11 @@ The following table lists the Visual C++ compiler `_MSC_VER` for each Visual Stu
106
109
| Visual Studio 2022 version 17.9 | 1939 |
107
110
| Visual Studio 2022 version 17.10 | 1940 |
108
111
109
-
<sup>a</sup> Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. `_MSC_FULL_VER` for 16.8 is 192829333. `_MSC_FULL_VER` for 16.9 is 192829910.
112
+
<sup>a</sup> Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_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.
110
113
111
-
<sup>b</sup> Visual Studio 2019 16.10 and 16.11 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. `_MSC_FULL_VER` for 16.10 is 192933037. `_MSC_FULL_VER` for 16.11 is 192930133.
114
+
<sup>b</sup> Visual Studio 2019 16.10 and 16.11 share the same major and minor versions (and `_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.
Copy file name to clipboardExpand all lines: docs/preprocessor/predefined-macros.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ The compiler supports these predefined macros specified by the ISO C99, C11, C17
38
38
39
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.
40
40
41
-
-`__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.
42
42
43
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.
44
44
@@ -244,8 +244,9 @@ MSVC supports other predefined macros:
244
244
245
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.
246
246
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. 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. `_MSC_FULL_VER` must be used to distinguish between Visual Studio 2019 16.8 and 16.9 because those versions share the same major and minor versions (and `_MSC_VER`). The same is true for Visual Studio 2019 16.10 and 16.11.
248
-
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. For example, if the Microsoft C/C++ compiler version is 19.39.33519, `_MSC_FULL_VER` evaluates to 193933519. Enter `cl /?` at the command line to view the compiler's version number. This macro is always defined.
248
+
Visual Studio 2019 16.8 and 16.9 share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The minimum value of `_MSC_FULL_VER` for 16.8 is 192829333. The minimum value of `_MSC_FULL_VER` for 16.9 is 192829910.
249
+
Visual Studio 2019 16.10 and 16.11 also share the same major and minor versions (and `_MSC_VER`). To distinguish them, use `_MSC_FULL_VER`. The minimum value of `_MSC_FULL_VER` for 16.10 is 192929917. The minimum value of `_MSC_FULL_VER` for 16.11 is 192930129.
249
250
- `_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.
250
251
251
252
See [C++ compiler versioning](../overview/compiler-versions.md) for more information about the history of compiler versioning, and compiler version numbers and the Visual Studio versions they correspond to.
@@ -262,7 +263,8 @@ MSVC supports other predefined macros:
262
263
#endif
263
264
```
264
265
265
-
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.
266
+
To test for compiler versions that share major and minor numbers, use the major, minor, and build numbers in `_MSC_FULL_VER` for comparisons. `_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.
267
+
Visual Studio 2019 16.10 and 16.11 also share the same major and minor versions (and `_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.
266
268
267
269
For more information about compiler versioning, see [Visual C++ Compiler Version](https://devblogs.microsoft.com/cppblog/visual-c-compiler-version/) in the Microsoft C++ Team Blog.
268
270
@@ -315,9 +317,9 @@ MSVC supports other predefined macros:
315
317
316
318
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.
317
319
318
-
- `_ATL_VER` Defined in \<atldef.h> as an integer literal that encodes the ATL version number.
320
+
- `_ATL_VER` Defined in `<atldef.h>` as an integer literal that encodes the ATL version number.
319
321
320
-
- `_MFC_VER` Defined in \<afxver_.h> as an integer literal that encodes the MFC version number.
322
+
- `_MFC_VER` Defined in `<afxver_.h>` as an integer literal that encodes the MFC version number.
0 commit comments