I have Microsoft Visual Studio 2022 installed and when I open from IDE the menu item Help->About Microsoft Visual Studio it shows Version 17.7.7 (explicitly saying "Current" for my product) and all the related components have versions 17.*
At the same time godbolt.org suggests x64 msvc v19.37 as the latest version of the compiler and the code blow
#include <print>
int main() {
std::print("{}", _MSC_VER);
}
being run on my version of Microsoft Visual Studio 2022 gives the same
1937
Why these versions differ and is there a way to see the msvc compiler version installed from IDE or command line?
2
Answers
TL;DR:
1937
is the correct_MSC_VER
for VS2022 (aka VS 17.7)Since the release of Visual Studio 2017, the value of the
_MSC_VER
is entirely unrelated to the ostensible version number (or marketing version number, or release year, or anything, really) of Visual Studio:https://devblogs.microsoft.com/cppblog/visual-c-compiler-version/
Microsoft has published a table mapping
_MSC_VER
values to Visual Studio releases on their Predefined Macros page.…which I’ve repeated here for posterity:
_MSC_VER
Macro
_MSC_VER
translates to the version number of the compiler rather than the version of the IDE. This is explained here in learn.microsoft.com.One way to find the current version of Visual Studio is to execute
vswhere.exe
and evaluate its output.This tool is located in the home directory of the Visual Studio installer
vs_installer
("C:Program Files (x86)Microsoft Visual StudioInstaller"
on my system).The respective output line is something like:
From the Developer Command Prompt of Visual Studio, I get: