compilers: correct the MSVC version comparison for turning on __cplusplus

We compared a Visual Studio (the IDE) version, but we wanted a MSVC (the
compiler) version. This caused the option to be passed for a few too
many versions of MSVC, and emit a "D9002 : ignoring unknown option" on
those systems.

Compare the correct version using the version mapping from
https://walbourn.github.io/vs-2017-15-7-update/

Fixes #10787

Co-authored-by: CorrodedCoder <38778644+CorrodedCoder@users.noreply.github.com>
pull/10790/head
Eli Schwartz 2 years ago
parent 7bdfe7ccb2
commit 167356aeab
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/compilers/cpp.py

@ -740,7 +740,7 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi
# By default, MSVC has a broken __cplusplus define that pretends to be c++98:
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
# Pass the flag to enable a truthful define, if possible.
if version_compare(self.version, '>= 15.7') and '/Zc:__cplusplus' not in args:
if version_compare(self.version, '>= 19.14.26428') and '/Zc:__cplusplus' not in args:
return args + ['/Zc:__cplusplus']
return args

Loading…
Cancel
Save