diff options
author | Olly Betts <olly@survex.com> | 2022-07-25 11:42:41 +1200 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2022-07-25 11:51:51 +1200 |
commit | 2bfeecc1d509874d482f8336884bfeeeaf0ba077 (patch) | |
tree | 002db0ab9482f281b2e607cee7d06683bccd2cc5 | |
parent | 066994d9ac192f8ada9414224aa2ee7e2d38b821 (diff) | |
download | autoconf-archive-2bfeecc1d509874d482f8336884bfeeeaf0ba077.tar.gz |
ax_cxx_compile_stdcxx: Fix for MSVC
MSVC always sets __cplusplus to 199711L in older versions; newer versions
do the same unless /Zc:__cplusplus is specified as well as a /std:c++<NN>
switch:
https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
This fixes a regression compared to the old separate
AX_CXX_COMPILE_STDCXX_11, etc macros which didn't check the value of
__cplusplus so worked OK with MSVC.
-rw-r--r-- | m4/ax_cxx_compile_stdcxx.m4 | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 51a3505..a3d964c 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -43,7 +43,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 14 +#serial 15 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -189,7 +189,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -480,7 +484,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201402L +#elif __cplusplus < 201402L && !defined _MSC_VER #error "This is not a C++14 compiler" @@ -604,7 +608,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201703L +#elif __cplusplus < 201703L && !defined _MSC_VER #error "This is not a C++17 compiler" @@ -970,7 +974,7 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus < 201703L +#endif // __cplusplus < 201703L && !defined _MSC_VER ]]) @@ -983,7 +987,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 202002L +#elif __cplusplus < 202002L && !defined _MSC_VER #error "This is not a C++20 compiler" @@ -1000,6 +1004,6 @@ namespace cxx20 } // namespace cxx20 -#endif // __cplusplus < 202002L +#endif // __cplusplus < 202002L && !defined _MSC_VER ]]) |