Skip to content

Commit 4e21d67

Browse files
committed
Update m4_ax_cxx_compile_stdcxx to serial 18
Grab latest from upstream autoconf archive. To try out msvc to fix /std:c++11 unsupported warnings.
1 parent f52d466 commit 4e21d67

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

Tools/config/m4_ax_cxx_compile_stdcxx.m4

+22-9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# and this notice are preserved. This file is offered as-is, without any
4444
# warranty.
4545

46-
#serial 14
46+
#serial 18
4747

4848
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
4949
dnl (serial version number 13).
@@ -104,9 +104,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
104104
dnl HP's aCC needs +std=c++11 according to:
105105
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
106106
dnl Cray's crayCC needs "-h std=c++11"
107+
dnl MSVC needs -std:c++NN for C++17 and later (default is C++14)
107108
for alternative in ${ax_cxx_compile_alternatives}; do
108-
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
109-
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
109+
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
110+
if test x"$switch" = xMSVC; then
111+
dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide
112+
dnl with -std=c++17. We suffix the cache variable name with _MSVC to
113+
dnl avoid this.
114+
switch=-std:c++${alternative}
115+
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC])
116+
else
117+
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
118+
fi
110119
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
111120
$cachevar,
112121
[ac_save_CXX="$CXX"
@@ -189,7 +198,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
189198
190199
#error "This is not a C++ compiler"
191200
192-
#elif __cplusplus < 201103L
201+
// MSVC always sets __cplusplus to 199711L in older versions; newer versions
202+
// only set it correctly if /Zc:__cplusplus is specified as well as a
203+
// /std:c++NN switch:
204+
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
205+
#elif __cplusplus < 201103L && !defined _MSC_VER
193206
194207
#error "This is not a C++11 compiler"
195208
@@ -480,7 +493,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
480493
481494
#error "This is not a C++ compiler"
482495
483-
#elif __cplusplus < 201402L
496+
#elif __cplusplus < 201402L && !defined _MSC_VER
484497
485498
#error "This is not a C++14 compiler"
486499
@@ -604,7 +617,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
604617
605618
#error "This is not a C++ compiler"
606619
607-
#elif __cplusplus < 201703L
620+
#elif __cplusplus < 201703L && !defined _MSC_VER
608621
609622
#error "This is not a C++17 compiler"
610623
@@ -970,7 +983,7 @@ namespace cxx17
970983
971984
} // namespace cxx17
972985
973-
#endif // __cplusplus < 201703L
986+
#endif // __cplusplus < 201703L && !defined _MSC_VER
974987
975988
]])
976989

@@ -983,7 +996,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
983996
984997
#error "This is not a C++ compiler"
985998
986-
#elif __cplusplus < 202002L
999+
#elif __cplusplus < 202002L && !defined _MSC_VER
9871000
9881001
#error "This is not a C++20 compiler"
9891002
@@ -1000,6 +1013,6 @@ namespace cxx20
10001013
10011014
} // namespace cxx20
10021015
1003-
#endif // __cplusplus < 202002L
1016+
#endif // __cplusplus < 202002L && !defined _MSC_VER
10041017
10051018
]])

0 commit comments

Comments
 (0)