◐ Shell
clean mode source ↗

gh-99191: Use correct check for MSVC C++ version support in _wmimodule.cpp by CAM-Gerlach · Pull Request #100381 · python/cpython

As discussed in #99191 , in PC/_wmimodule.cpp it currently uses the check #if _MSC_VER >= 1929 to determine if the compiler supports C++20 designated initializers. However, the /std:c++20 flag was only introduced in VS 2019 16.11, but 1929 is also the version reported in VS 2019 16.10, which doesn't support that flag. Therefore, the current check will break (resulting in the unsupported C++20 branch being taken and presumably resulting in a compiler error) on VS 16.10 and also if the build is invoked such that \std:c++20 is overridden or not passed.

However, we can instead use _MSVC_LANG >= 202002L to check whether C++20 or greater is actually being targeted.

Fixes #99191