4 # Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
6 # This implementation is taken from GNU Autoconf lib/autoconf/c.m4
7 # commit 017d5ddd82854911f0119691d91ea8a1438824d6
8 # dated Sun Apr 3 13:57:17 2016 -0700
9 # This implementation will be obsolete once we can assume Autoconf 2.70
10 # or later is installed everywhere a Gnulib program might be developed.
12 m4_version_prereq([2.70], [], [
15 # Copyright (C) 2001-2024 Free Software Foundation, Inc.
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation, either version 3 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program. If not, see <https://www.gnu.org/licenses/>.
30 # Written by David MacKenzie, with help from
31 # Akim Demaille, Paul Eggert,
32 # François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
33 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
36 # AC_PROG_CC([COMPILER ...])
37 # --------------------------
38 # COMPILER ... is a space separated list of C compilers to search for.
39 # This just gives the user an opportunity to specify an alternative
40 # search list for the C compiler.
41 AC_DEFUN_ONCE([AC_PROG_CC],
43 AC_ARG_VAR([CC], [C compiler command])dnl
44 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
45 _AC_ARG_VAR_LDFLAGS()dnl
47 _AC_ARG_VAR_CPPFLAGS()dnl
49 [AC_CHECK_TOOLS(CC, [$1])],
50 [AC_CHECK_TOOL(CC, gcc)
51 if test -z "$CC"; then
53 dnl AC_CHECK_TOOL(CC, cc)
54 dnl but without the check for a tool without the prefix.
55 dnl Until the check is removed from there, copy the code:
56 if test -n "$ac_tool_prefix"; then
57 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
60 if test -z "$CC"; then
61 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
63 if test -z "$CC"; then
64 AC_CHECK_TOOLS(CC, cl.exe)
66 if test -z "$CC"; then
67 AC_CHECK_TOOL(CC, clang)
71 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
73 # Provide some information about the compiler.
74 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
77 for ac_option in --version -v -V -qversion -version; do
78 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
81 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
82 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
84 if test $ac_compiler_gnu = yes; then
91 dnl Set ac_prog_cc_stdc to the supported C version.
92 dnl Also set the documented variable ac_cv_prog_cc_stdc;
93 dnl its name was chosen when it was cached, but it is no longer cached.
94 _AC_PROG_CC_C11([ac_prog_cc_stdc=c11
95 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
96 [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
97 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
98 [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
99 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
101 ac_cv_prog_cc_stdc=no])])])
108 # AC_PROG_CXX([LIST-OF-COMPILERS])
109 # --------------------------------
110 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
111 # for (if not specified, a default list is used). This just gives the
112 # user an opportunity to specify an alternative search list for the C++
114 # aCC HP-UX C++ compiler much better than `CC', so test before.
115 # FCC Fujitsu C++ compiler
116 # KCC KAI C++ compiler
118 # xlC_r AIX C Set++ (with support for reentrant code)
120 AC_DEFUN([AC_PROG_CXX],
121 [AC_LANG_PUSH(C++)dnl
122 AC_ARG_VAR([CXX], [C++ compiler command])dnl
123 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
124 _AC_ARG_VAR_LDFLAGS()dnl
125 _AC_ARG_VAR_LIBS()dnl
126 _AC_ARG_VAR_CPPFLAGS()dnl
127 _AC_ARG_VAR_PRECIOUS([CCC])dnl
128 if test -z "$CXX"; then
129 if test -n "$CCC"; then
134 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
138 # Provide some information about the compiler.
139 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
142 for ac_option in --version -v -V -qversion; do
143 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
146 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
147 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
148 _AC_LANG_COMPILER_GNU
149 if test $ac_compiler_gnu = yes; then
155 _AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
156 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
157 ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
158 [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
159 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
160 [ac_prog_cxx_stdcxx=no
161 ac_cv_prog_cxx_stdcxx=no])])
166 # _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
167 # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
168 # --------------------------------------------------------------
169 # Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
170 # by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
171 # try again with each compiler option in the space-separated OPTION-LIST; if one
172 # helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
173 # else ACTION-IF-UNAVAILABLE.
174 AC_DEFUN([_AC_C_STD_TRY],
175 [AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
176 AC_CACHE_VAL(ac_cv_prog_cc_$1,
179 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
182 CC="$ac_save_CC $ac_arg"
183 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
184 test "x$ac_cv_prog_cc_$1" != "xno" && break
186 rm -f conftest.$ac_ext
189 ac_prog_cc_stdc_options=
190 case "x$ac_cv_prog_cc_$1" in
192 AC_MSG_RESULT([none needed]) ;;
194 AC_MSG_RESULT([unsupported]) ;;
196 ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
197 CC=$CC$ac_prog_cc_stdc_options
198 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
200 AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
203 # _AC_C_C99_TEST_HEADER
204 # ---------------------
205 # A C header suitable for testing for C99.
206 AC_DEFUN([_AC_C_C99_TEST_HEADER],
207 [[#include <stdarg.h>
214 // Check varargs macros. These examples are taken from C99 6.10.3.5.
215 #define debug(...) fprintf (stderr, __VA_ARGS__)
216 #define showlist(...) puts (#__VA_ARGS__)
217 #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
219 test_varargs_macros (void)
224 debug ("X = %d\n", x);
225 showlist (The first, second, and third items.);
226 report (x>y, "x is %d but y is %d", x, y);
229 // Check long long types.
230 #define BIG64 18446744073709551615ull
231 #define BIG32 4294967295ul
232 #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
234 your preprocessor is broken;
238 your preprocessor is broken;
240 static long long int bignum = -9223372036854775807LL;
241 static unsigned long long int ubignum = BIG64;
243 struct incomplete_array
255 typedef const char *ccp;
258 test_restrict (ccp restrict text)
260 // See if C++-style comments work.
261 // Iterate through items via the restricted pointer.
262 // Also check for declarations in for loops.
263 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
268 // Check varargs and va_copy.
270 test_varargs (const char *format, ...)
273 va_start (args, format);
275 va_copy (args_copy, args);
277 const char *str = "";
286 str = va_arg (args_copy, const char *);
289 number = va_arg (args_copy, int);
292 fnumber = va_arg (args_copy, double);
301 return *str && number && fnumber;
302 }]])# _AC_C_C99_TEST_HEADER
304 # _AC_C_C99_TEST_BODY
305 # -------------------
306 # A C body suitable for testing for C99, assuming the corresponding header.
307 AC_DEFUN([_AC_C_C99_TEST_BODY],
310 _Bool success = false;
313 if (test_restrict ("String literal") == 0)
315 char *restrict newvar = "Another string";
318 success &= test_varargs ("s, d' f .", "string", 65, 34.234);
319 test_varargs_macros ();
321 // Check flexible array members.
322 struct incomplete_array *ia =
323 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
325 for (int i = 0; i < ia->datasize; ++i)
326 ia->data[i] = i * 1.234;
328 // Check named initializers.
329 struct named_init ni = {
331 .name = L"Test wide string",
332 .average = 543.34343,
337 int dynamic_array[ni.number];
338 dynamic_array[ni.number - 1] = 543;
340 // work around unused variable warnings
341 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
342 || dynamic_array[ni.number - 1] != 543);
345 # _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
346 # ----------------------------------------------------------------
347 # If the C compiler is not in ISO C99 mode by default, try to add an
348 # option to output variable CC to make it so. This macro tries
349 # various options that select ISO C99 on some system or another. It
350 # considers the compiler to be in ISO C99 mode if it handles _Bool,
351 # // comments, flexible array members, inline, long long int, mixed
352 # code and declarations, named initialization of structs, restrict,
353 # va_copy, varargs macros, variable declarations in for loops and
354 # variable length arrays.
355 AC_DEFUN([_AC_PROG_CC_C99],
356 [_AC_C_STD_TRY([c99],
357 [_AC_C_C99_TEST_HEADER],
358 [_AC_C_C99_TEST_BODY],
360 dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
361 dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
362 dnl IBM XL C -qlanglvl=extc99
363 dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
365 dnl Intel ICC -std=c99, -c99 (deprecated)
367 dnl Solaris -D_STDC_C99=
368 dnl cc's -xc99 option uses linker magic to define the external
369 dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
370 dnl behavior for C library functions. This is not wanted here,
371 dnl because it means that a single module compiled with -xc99
372 dnl alters C runtime behavior for the entire program, not for
373 dnl just the module. Instead, define the (private) symbol
374 dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
375 dnl The resulting compiler passes the test case here, and that's
376 dnl good enough. For more, please see the thread starting at:
377 dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
379 dnl with extended modes being tried first.
380 [[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
384 # _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
385 # ----------------------------------------------------------------
386 # If the C compiler is not in ISO C11 mode by default, try to add an
387 # option to output variable CC to make it so. This macro tries
388 # various options that select ISO C11 on some system or another. It
389 # considers the compiler to be in ISO C11 mode if it handles _Alignas,
390 # _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
391 # duplicate typedefs, and anonymous structures and unions.
392 AC_DEFUN([_AC_PROG_CC_C11],
393 [_AC_C_STD_TRY([c11],
394 [_AC_C_C99_TEST_HEADER[
396 char _Alignas (double) aligned_as_double;
397 char _Alignas (0) no_special_alignment;
398 extern char aligned_as_int;
399 char _Alignas (0) _Alignas (int) aligned_as_int;
404 int_alignment = _Alignof (int),
405 int_array_alignment = _Alignof (int[100]),
406 char_alignment = _Alignof (char)
408 _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
411 int _Noreturn does_not_return (void) { for (;;) continue; }
413 // Check _Static_assert.
414 struct test_static_assert
417 _Static_assert (sizeof (int) <= sizeof (long int),
418 "_Static_assert does not work in struct");
422 // Check UTF-8 literals.
423 #define u8 syntax error!
424 char const utf8_literal[] = u8"happens to be ASCII" "another string";
426 // Check duplicate typedefs.
427 typedef long *long_ptr;
428 typedef long int *long_ptr;
429 typedef long_ptr long_ptr;
431 // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
435 struct { int i; int j; };
436 struct { int k; long int l; } w;
441 [_AC_C_C99_TEST_BODY[
444 _Static_assert ((offsetof (struct anonymous, i)
445 == offsetof (struct anonymous, w.k)),
446 "Anonymous union alignment botch");
449 dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
450 dnl with extended modes being tried first.
452 dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
453 dnl of September 2012) does not pass the C11 test. For now, try extc1x when
454 dnl compiling the C99 test instead, since it enables _Static_assert and
455 dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
456 dnl the C11 test in some future version of IBM XL C, we'll add it here,
457 dnl preferably extc11.
458 [[-std=gnu11]], [$1], [$2])[]dnl
464 # Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
465 # as that'd be incompatible with how Automake redefines AC_PROG_CC. See
466 # <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
467 AU_DEFUN([AC_PROG_CC_C89],
468 [AC_REQUIRE([AC_PROG_CC])],
469 [$0 is obsolete; use AC_PROG_CC]
474 AU_DEFUN([AC_PROG_CC_C99],
475 [AC_REQUIRE([AC_PROG_CC])],
476 [$0 is obsolete; use AC_PROG_CC]
481 AU_DEFUN([AC_PROG_CC_STDC],
482 [AC_REQUIRE([AC_PROG_CC])],
483 [$0 is obsolete; use AC_PROG_CC]
489 # Check if the C compiler supports prototypes, included if it needs
491 AC_DEFUN([AC_C_PROTOTYPES],
492 [AC_REQUIRE([AC_PROG_CC])dnl
493 if test "$ac_prog_cc_stdc" != no; then
494 AC_DEFINE(PROTOTYPES, 1,
495 [Define to 1 if the C compiler supports function prototypes.])
496 AC_DEFINE(__PROTOTYPES, 1,
497 [Define like PROTOTYPES; this can be used by system headers.])
502 # _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
503 # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
504 # ----------------------------------------------------------------
505 # Check whether the C++ compiler accepts features of STANDARD (e.g
506 # `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
507 # and TEST-BODY. If this fails, try again with each compiler option
508 # in the space-separated OPTION-LIST; if one helps, append it to CXX.
509 # If eventually successful, run ACTION-IF-AVAILABLE, else
510 # ACTION-IF-UNAVAILABLE.
511 AC_DEFUN([_AC_CXX_STD_TRY],
512 [AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
514 AC_CACHE_VAL(ac_cv_prog_cxx_$1,
515 [ac_cv_prog_cxx_$1=no
517 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
520 CXX="$ac_save_CXX $ac_arg"
521 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
522 test "x$ac_cv_prog_cxx_$1" != "xno" && break
524 rm -f conftest.$ac_ext
527 ac_prog_cxx_stdcxx_options=
528 case "x$ac_cv_prog_cxx_$1" in
530 AC_MSG_RESULT([none needed]) ;;
532 AC_MSG_RESULT([unsupported]) ;;
534 ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
535 CXX=$CXX$ac_prog_cxx_stdcxx_options
536 AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
539 AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
542 # _AC_CXX_CXX98_TEST_HEADER
543 # -------------------------
544 # A C++ header suitable for testing for CXX98.
545 AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
562 typedef std::vector<std::string> string_vec;
563 typedef std::pair<int,bool> map_value;
564 typedef std::map<std::string,map_value> map_type;
565 typedef std::set<int> set_type;
570 printer(std::ostringstream& os): os(os) {}
571 void operator() (T elem) { os << elem << std::endl; }
573 std::ostringstream& os;
576 ]])# _AC_CXX_CXX98_TEST_HEADER
578 # _AC_CXX_CXX98_TEST_BODY
579 # -----------------------
580 # A C++ body suitable for testing for CXX98, assuming the corresponding header.
581 AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
586 std::string teststr("ASCII text");
587 teststr += " string";
590 test::string_vec testvec;
591 testvec.push_back(teststr);
592 testvec.push_back("foo");
593 testvec.push_back("bar");
594 if (testvec.size() != 3) {
595 throw std::runtime_error("vector size is not 1");
598 // Dump vector into stringstream and obtain string.
599 std::ostringstream os;
600 for (test::string_vec::const_iterator i = testvec.begin();
601 i != testvec.end(); ++i) {
602 if (i + 1 != testvec.end()) {
603 os << teststr << '\n';
606 // Check algorithms work.
607 std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
608 std::string os_out = os.str();
610 // Test pair and map.
611 test::map_type testmap;
612 testmap.insert(std::make_pair(std::string("key"),
613 std::make_pair(53,false)));
616 int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
617 test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
618 std::list<int> testlist(testset.begin(), testset.end());
619 std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
620 } catch (const std::exception& e) {
621 std::cerr << "Caught exception: " << e.what() << std::endl;
624 std::ofstream of("test.txt");
625 of << "Test ASCII text\n" << std::flush;
626 of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
632 # _AC_CXX_CXX11_TEST_HEADER
633 # -------------------------
634 # A C++ header suitable for testing for CXX11.
635 AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
638 #include <functional>
647 typedef std::shared_ptr<std::string> sptr;
648 typedef std::weak_ptr<std::string> wptr;
650 typedef std::tuple<std::string,int,double> tp;
651 typedef std::array<int, 20> int_array;
653 constexpr int get_val() { return 20; }
663 delegate(int n) : n(n) {}
664 delegate(): delegate(2354) {}
666 virtual int getval() { return this->n; };
671 class overridden : public delegate {
673 overridden(int n): delegate(n) {}
674 virtual int getval() override final { return this->n * 2; }
679 nocopy(int i): i(i) {}
681 nocopy(const nocopy&) = delete;
682 nocopy & operator=(const nocopy&) = delete;
687 ]])# _AC_CXX_CXX11_TEST_HEADER
689 # _AC_CXX_CXX11_TEST_BODY
690 # -----------------------
691 # A C++ body suitable for testing for CXX11, assuming the corresponding header.
692 AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
695 // Test auto and decltype
702 for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
705 auto a2 = 48573953.4;
706 auto a3 = "String literal";
708 decltype(a2) a4 = 34895.034;
712 short sa[cxx11test::get_val()] = { 0 };
715 // Test initializer lists
716 cxx11test::testinit il = { 4323, 435234.23544 };
719 // Test range-based for and lambda
720 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
721 for (int &x : array) { x += 23; }
722 std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
725 using cxx11test::sptr;
726 using cxx11test::wptr;
728 sptr sp(new std::string("ASCII string"));
733 cxx11test::tp tuple("test", 54, 45.53434);
734 double d = std::get<2>(tuple);
737 std::tie(s,i,d) = tuple;
740 static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
741 std::string testmatch("Test if this string matches");
742 bool match = std::regex_search(testmatch, filename_regex);
745 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
746 cxx11test::int_array::size_type size = array.size();
749 // Test constructor delegation
750 cxx11test::delegate d1;
751 cxx11test::delegate d2();
752 cxx11test::delegate d3(45);
755 // Test override and final
756 cxx11test::overridden o1(55464);
763 // Test template brackets
764 std::vector<std::pair<int,char*>> v1;
768 char const *utf8 = u8"UTF-8 string \u2500";
769 char16_t const *utf16 = u"UTF-8 string \u2500";
770 char32_t const *utf32 = U"UTF-32 string \u2500";
774 # _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
775 # -------------------------------------------------------------------
777 # If the C++ compiler is not in ISO C++98 mode by default, try to add
778 # an option to output variable CXX to make it so. This macro tries
779 # various options that select ISO C++98 on some system or another. It
780 # considers the compiler to be in ISO C++98 mode if it handles basic
781 # features of the std namespace including: string, containers (list,
782 # map, set, vector), streams (fstreams, iostreams, stringstreams,
783 # iomanip), pair, exceptions and algorithms.
786 AC_DEFUN([_AC_PROG_CXX_CXX98],
787 [_AC_CXX_STD_TRY([cxx98],
788 [_AC_CXX_CXX98_TEST_HEADER],
789 [_AC_CXX_CXX98_TEST_BODY],
791 dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
792 dnl IBM XL C -qlanglvl=extended
794 dnl Intel ICC -std=gnu++98
795 dnl Solaris N/A (default)
796 dnl Tru64 N/A (default, but -std gnu could be used)
797 dnl with extended modes being tried first.
798 [[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
799 ])# _AC_PROG_CXX_CXX98
801 # _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
802 # -------------------------------------------------------------------
803 # If the C++ compiler is not in ISO CXX11 mode by default, try to add
804 # an option to output variable CXX to make it so. This macro tries
805 # various options that select ISO C++11 on some system or another. It
806 # considers the compiler to be in ISO C++11 mode if it handles all the
807 # tests from the C++98 checks, plus the following: Language features
808 # (auto, constexpr, decltype, default/deleted constructors, delegate
809 # constructors, final, initializer lists, lambda functions, nullptr,
810 # override, range-based for loops, template brackets without spaces,
811 # unicode literals) and library features (array, memory (shared_ptr,
812 # weak_ptr), regex and tuple types).
813 AC_DEFUN([_AC_PROG_CXX_CXX11],
814 [_AC_CXX_STD_TRY([cxx11],
815 [_AC_CXX_CXX11_TEST_HEADER
816 _AC_CXX_CXX98_TEST_HEADER],
817 [_AC_CXX_CXX11_TEST_BODY
818 _AC_CXX_CXX98_TEST_BODY],
820 dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
821 dnl IBM XL C -qlanglvl=extended0x
822 dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
824 dnl Intel ICC -std=c++11 -std=c++0x
825 dnl Solaris N/A (no support)
826 dnl Tru64 N/A (no support)
827 dnl with extended modes being tried first.
828 [[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
829 ])# _AC_PROG_CXX_CXX11
832 ])# m4_version_prereq