diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-04-27 19:25:27 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-05-08 14:40:54 -0400 |
commit | 04c728a126cc484cda21d21d672630d298cae9b8 (patch) | |
tree | a94355772115790675f67e79932f3d3dc2157d5c /docs | |
parent | 3ae36dee42e0152ed24a385fdd6035a391f5322f (diff) | |
download | meson-04c728a126cc484cda21d21d672630d298cae9b8.zip meson-04c728a126cc484cda21d21d672630d298cae9b8.tar.gz meson-04c728a126cc484cda21d21d672630d298cae9b8.tar.bz2 |
compilers/c++: Add MSVC option to make the __cplusplus define accurate
Otherwise it always returns the value for c++98, starting with MSVC 2017
15.7 or later. Earlier versions are not affected by this mis-feature.
See: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
This was originally applied as 0b97d585480e973d8b149618901f7a4ddfa1a906
but later reverted because it made the CI red. Try it again, now.
Original-patch-by: Dylan Baker <dylan@pnwbakers.com>
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/markdown/snippets/msvc_cplusplus_define.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/markdown/snippets/msvc_cplusplus_define.md b/docs/markdown/snippets/msvc_cplusplus_define.md new file mode 100644 index 0000000..2c5648d --- /dev/null +++ b/docs/markdown/snippets/msvc_cplusplus_define.md @@ -0,0 +1,15 @@ +## MSVC now sets the __cplusplus #define accurately + +MSVC will always return `199711L` for `__cplusplus`, even when a newer c++ +standard is explicitly requested, unless you pass a specific option to the +compiler for MSVC 2017 15.7 and newer. Older versions are unaffected by this. + +Microsoft's stated rationale is that "a lot of existing code appears to depend +on the value of this macro matching 199711L", therefore for compatibility with +such (MSVC-only) code they will require opting in to the standards-conformant +value. + +Meson now always sets the option if it is available, as it is unlikely that +users want the default behavior, and *impossible* to use the default behavior +in cross-platform code (which frequently breaks as soon as the first person +tries to compile using MSVC). |