aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-04-27 19:25:27 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-05-08 14:40:54 -0400
commit04c728a126cc484cda21d21d672630d298cae9b8 (patch)
treea94355772115790675f67e79932f3d3dc2157d5c /test cases
parent3ae36dee42e0152ed24a385fdd6035a391f5322f (diff)
downloadmeson-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 'test cases')
-rw-r--r--test cases/windows/18 msvc cplusplus define/main.cpp7
-rw-r--r--test cases/windows/18 msvc cplusplus define/meson.build14
-rw-r--r--test cases/windows/3 cpp/meson.build2
3 files changed, 22 insertions, 1 deletions
diff --git a/test cases/windows/18 msvc cplusplus define/main.cpp b/test cases/windows/18 msvc cplusplus define/main.cpp
new file mode 100644
index 0000000..bc0b1fd
--- /dev/null
+++ b/test cases/windows/18 msvc cplusplus define/main.cpp
@@ -0,0 +1,7 @@
+int main() {
+#if __cplusplus == 199711L
+ return 1;
+#else
+ return 0;
+#endif
+}
diff --git a/test cases/windows/18 msvc cplusplus define/meson.build b/test cases/windows/18 msvc cplusplus define/meson.build
new file mode 100644
index 0000000..9b85ff6
--- /dev/null
+++ b/test cases/windows/18 msvc cplusplus define/meson.build
@@ -0,0 +1,14 @@
+project('msvc __cplusplus', 'cpp', default_options : ['cpp_std=c++14'])
+
+cpp = meson.get_compiler('cpp')
+
+if cpp.get_id() != 'msvc'
+ error('MESON_SKIP_TEST: test is only relevant for msvc')
+elif meson.project_version().version_compare('< 15.7')
+ error('MESON_SKIP_TEST: test is only relevant for msvc versions >= 15.7')
+endif
+
+test(
+ 'main',
+ executable('main', 'main.cpp'),
+)
diff --git a/test cases/windows/3 cpp/meson.build b/test cases/windows/3 cpp/meson.build
index 7b8080e..a9e6569 100644
--- a/test cases/windows/3 cpp/meson.build
+++ b/test cases/windows/3 cpp/meson.build
@@ -1,4 +1,4 @@
-project('wincpp', 'cpp')
+project('wincpp', 'cpp', default_options : ['cpp_std=c++14'])
exe = executable('prog', 'prog.cpp')
test('wincpp', exe)