10
10
#
11
11
# Check for baseline language coverage in the compiler for the specified
12
12
# version of the C++ standard. If necessary, add switches to CXX and
13
- # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
14
- # or '14' (for the C++14 standard) .
13
+ # CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
14
+ # the respective C++ standard version .
15
15
#
16
16
# The second argument, if specified, indicates whether you insist on an
17
17
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
18
18
# -std=c++11). If neither is specified, you get whatever works, with
19
- # preference for an extended mode.
19
+ # preference for no added switch, and then for an extended mode.
20
20
#
21
21
# The third argument, if specified 'mandatory' or if left unspecified,
22
22
# indicates that baseline support for the specified C++ standard is
35
35
# Copyright (c) 2015 Moritz Klammler <[email protected] >
36
36
# Copyright (c) 2016, 2018 Krzesimir Nowak <[email protected] >
37
37
# Copyright (c) 2019 Enji Cooper <[email protected] >
38
+ # Copyright (c) 2020 Jason Merrill <[email protected] >
39
+ # Copyright (c) 2021 Jörn Heusipp <[email protected] >
38
40
#
39
41
# Copying and distribution of this file, with or without modification, are
40
42
# permitted in any medium without royalty provided the copyright notice
41
43
# and this notice are preserved. This file is offered as-is, without any
42
44
# warranty.
43
45
44
- # serial 11
46
+ # serial 14
45
47
46
48
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
47
49
dnl (serial version number 13).
@@ -50,6 +52,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
50
52
m4_if ( [ $1 ] , [ 11] , [ ax_cxx_compile_alternatives="11 0x"] ,
51
53
[ $1 ] , [ 14] , [ ax_cxx_compile_alternatives="14 1y"] ,
52
54
[ $1 ] , [ 17] , [ ax_cxx_compile_alternatives="17 1z"] ,
55
+ [ $1 ] , [ 20] , [ ax_cxx_compile_alternatives="20"] ,
53
56
[ m4_fatal ( [ invalid first argument `$1 ' to AX_CXX_COMPILE_STDCXX ] ) ] ) dnl
54
57
m4_if ( [ $2 ] , [ ] , [ ] ,
55
58
[ $2 ] , [ ext] , [ ] ,
@@ -62,6 +65,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
62
65
AC_LANG_PUSH ( [ C++] ) dnl
63
66
ac_success=no
64
67
68
+ m4_if ( [ $2 ] , [ ] , [ dnl
69
+ AC_CACHE_CHECK ( whether $CXX supports C++$1 features by default ,
70
+ ax_cv_cxx_compile_cxx$1 ,
71
+ [ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ _AX_CXX_COMPILE_STDCXX_testbody_$1 ] ) ] ,
72
+ [ ax_cv_cxx_compile_cxx$1 =yes] ,
73
+ [ ax_cv_cxx_compile_cxx$1 =no] ) ] )
74
+ if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
75
+ ac_success=yes
76
+ fi] )
77
+
65
78
m4_if ( [ $2 ] , [ noext] , [ ] , [ dnl
66
79
if test x$ac_success = xno; then
67
80
for alternative in ${ax_cxx_compile_alternatives}; do
@@ -140,20 +153,31 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
140
153
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
141
154
)
142
155
143
-
144
156
dnl Test body for checking C++14 support
145
157
146
158
m4_define ( [ _AX_CXX_COMPILE_STDCXX_testbody_14] ,
147
159
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
148
160
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
149
161
)
150
162
163
+ dnl Test body for checking C++17 support
164
+
151
165
m4_define ( [ _AX_CXX_COMPILE_STDCXX_testbody_17] ,
152
166
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
153
167
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
154
168
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
155
169
)
156
170
171
+ dnl Test body for checking C++20 support
172
+
173
+ m4_define ( [ _AX_CXX_COMPILE_STDCXX_testbody_20] ,
174
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
175
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
176
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
177
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_20
178
+ )
179
+
180
+
157
181
dnl Tests for new features in C++11
158
182
159
183
m4_define ( [ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11] , [ [
@@ -949,3 +973,33 @@ namespace cxx17
949
973
#endif // __cplusplus < 201703L
950
974
951
975
] ] )
976
+
977
+
978
+ dnl Tests for new features in C++20
979
+
980
+ m4_define ( [ _AX_CXX_COMPILE_STDCXX_testbody_new_in_20] , [ [
981
+
982
+ #ifndef __cplusplus
983
+
984
+ #error "This is not a C++ compiler"
985
+
986
+ #elif __cplusplus < 202002L
987
+
988
+ #error "This is not a C++20 compiler"
989
+
990
+ #else
991
+
992
+ #include <version>
993
+
994
+ namespace cxx20
995
+ {
996
+
997
+ // As C++20 supports feature test macros in the standard, there is no
998
+ // immediate need to actually test for feature availability on the
999
+ // Autoconf side.
1000
+
1001
+ } // namespace cxx20
1002
+
1003
+ #endif // __cplusplus < 202002L
1004
+
1005
+ ] ] )
0 commit comments