1 # Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
3 # This implementation is taken from GNU Autoconf lib/autoconf/c.m4
4 # commit 017d5ddd82854911f0119691d91ea8a1438824d6
5 # dated Sun Apr 3 13:57:17 2016 -0700
6 # This implementation will be obsolete once we can assume Autoconf 2.70
7 # or later is installed everywhere a Gnulib program might be developed.
9 m4_version_prereq([2.70], [], [
12 # Copyright (C) 2001-2022 Free Software Foundation, Inc.
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <https://www.gnu.org/licenses/>.
27 # Written by David MacKenzie, with help from
28 # Akim Demaille, Paul Eggert,
29 # François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
30 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
33 # AC_PROG_CC([COMPILER ...])
34 # --------------------------
35 # COMPILER ... is a space separated list of C compilers to search for.
36 # This just gives the user an opportunity to specify an alternative
37 # search list for the C compiler.
38 AC_DEFUN_ONCE([AC_PROG_CC],
40 AC_ARG_VAR([CC], [C compiler command])dnl
41 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
42 _AC_ARG_VAR_LDFLAGS()dnl
44 _AC_ARG_VAR_CPPFLAGS()dnl
46 [AC_CHECK_TOOLS(CC, [$1])],
47 [AC_CHECK_TOOL(CC, gcc)
48 if test -z "$CC"; then
50 dnl AC_CHECK_TOOL(CC, cc)
51 dnl but without the check for a tool without the prefix.
52 dnl Until the check is removed from there, copy the code:
53 if test -n "$ac_tool_prefix"; then
54 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
57 if test -z "$CC"; then
58 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
60 if test -z "$CC"; then
61 AC_CHECK_TOOLS(CC, cl.exe)
63 if test -z "$CC"; then
64 AC_CHECK_TOOL(CC, clang)
68 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
70 # Provide some information about the compiler.
71 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
74 for ac_option in --version -v -V -qversion -version; do
75 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
78 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
79 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
81 if test $ac_compiler_gnu = yes; then
88 dnl Set ac_prog_cc_stdc to the supported C version.
89 dnl Also set the documented variable ac_cv_prog_cc_stdc;
90 dnl its name was chosen when it was cached, but it is no longer cached.
91 _AC_PROG_CC_C11([ac_prog_cc_stdc=c11
92 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
93 [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
94 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
95 [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
96 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
98 ac_cv_prog_cc_stdc=no])])])
105 # AC_PROG_CXX([LIST-OF-COMPILERS])
106 # --------------------------------
107 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
108 # for (if not specified, a default list is used). This just gives the
109 # user an opportunity to specify an alternative search list for the C++
111 # aCC HP-UX C++ compiler much better than `CC', so test before.
112 # FCC Fujitsu C++ compiler
113 # KCC KAI C++ compiler
115 # xlC_r AIX C Set++ (with support for reentrant code)
117 AC_DEFUN([AC_PROG_CXX],
118 [AC_LANG_PUSH(C++)dnl
119 AC_ARG_VAR([CXX], [C++ compiler command])dnl
120 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
121 _AC_ARG_VAR_LDFLAGS()dnl
122 _AC_ARG_VAR_LIBS()dnl
123 _AC_ARG_VAR_CPPFLAGS()dnl
124 _AC_ARG_VAR_PRECIOUS([CCC])dnl
125 if test -z "$CXX"; then
126 if test -n "$CCC"; then
131 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
135 # Provide some information about the compiler.
136 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
139 for ac_option in --version -v -V -qversion; do
140 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
143 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
144 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
145 _AC_LANG_COMPILER_GNU
146 if test $ac_compiler_gnu = yes; then
152 _AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
153 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
154 ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
155 [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
156 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
157 [ac_prog_cxx_stdcxx=no
158 ac_cv_prog_cxx_stdcxx=no])])
163 # _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
164 # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
165 # --------------------------------------------------------------
166 # Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
167 # by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
168 # try again with each compiler option in the space-separated OPTION-LIST; if one
169 # helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
170 # else ACTION-IF-UNAVAILABLE.
171 AC_DEFUN([_AC_C_STD_TRY],
172 [AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
173 AC_CACHE_VAL(ac_cv_prog_cc_$1,
176 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
179 CC="$ac_save_CC $ac_arg"
180 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
181 test "x$ac_cv_prog_cc_$1" != "xno" && break
183 rm -f conftest.$ac_ext
186 ac_prog_cc_stdc_options=
187 case "x$ac_cv_prog_cc_$1" in
189 AC_MSG_RESULT([none needed]) ;;
191 AC_MSG_RESULT([unsupported]) ;;
193 ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
194 CC=$CC$ac_prog_cc_stdc_options
195 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
197 AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
200 # _AC_C_C99_TEST_HEADER
201 # ---------------------
202 # A C header suitable for testing for C99.
203 AC_DEFUN([_AC_C_C99_TEST_HEADER],
204 [[#include <stdarg.h>
211 // Check varargs macros. These examples are taken from C99 6.10.3.5.
212 #define debug(...) fprintf (stderr, __VA_ARGS__)
213 #define showlist(...) puts (#__VA_ARGS__)
214 #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
216 test_varargs_macros (void)
221 debug ("X = %d\n", x);
222 showlist (The first, second, and third items.);
223 report (x>y, "x is %d but y is %d", x, y);
226 // Check long long types.
227 #define BIG64 18446744073709551615ull
228 #define BIG32 4294967295ul
229 #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
231 your preprocessor is broken;
235 your preprocessor is broken;
237 static long long int bignum = -9223372036854775807LL;
238 static unsigned long long int ubignum = BIG64;
240 struct incomplete_array
252 typedef const char *ccp;
255 test_restrict (ccp restrict text)
257 // See if C++-style comments work.
258 // Iterate through items via the restricted pointer.
259 // Also check for declarations in for loops.
260 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
265 // Check varargs and va_copy.
267 test_varargs (const char *format, ...)
270 va_start (args, format);
272 va_copy (args_copy, args);
274 const char *str = "";
283 str = va_arg (args_copy, const char *);
286 number = va_arg (args_copy, int);
289 fnumber = va_arg (args_copy, double);
298 return *str && number && fnumber;
299 }]])# _AC_C_C99_TEST_HEADER
301 # _AC_C_C99_TEST_BODY
302 # -------------------
303 # A C body suitable for testing for C99, assuming the corresponding header.
304 AC_DEFUN([_AC_C_C99_TEST_BODY],
307 _Bool success = false;
310 if (test_restrict ("String literal") == 0)
312 char *restrict newvar = "Another string";
315 success &= test_varargs ("s, d' f .", "string", 65, 34.234);
316 test_varargs_macros ();
318 // Check flexible array members.
319 struct incomplete_array *ia =
320 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
322 for (int i = 0; i < ia->datasize; ++i)
323 ia->data[i] = i * 1.234;
325 // Check named initializers.
326 struct named_init ni = {
328 .name = L"Test wide string",
329 .average = 543.34343,
334 int dynamic_array[ni.number];
335 dynamic_array[ni.number - 1] = 543;
337 // work around unused variable warnings
338 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
339 || dynamic_array[ni.number - 1] != 543);
342 # _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
343 # ----------------------------------------------------------------
344 # If the C compiler is not in ISO C99 mode by default, try to add an
345 # option to output variable CC to make it so. This macro tries
346 # various options that select ISO C99 on some system or another. It
347 # considers the compiler to be in ISO C99 mode if it handles _Bool,
348 # // comments, flexible array members, inline, long long int, mixed
349 # code and declarations, named initialization of structs, restrict,
350 # va_copy, varargs macros, variable declarations in for loops and
351 # variable length arrays.
352 AC_DEFUN([_AC_PROG_CC_C99],
353 [_AC_C_STD_TRY([c99],
354 [_AC_C_C99_TEST_HEADER],
355 [_AC_C_C99_TEST_BODY],
357 dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
358 dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
359 dnl IBM XL C -qlanglvl=extc99
360 dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
362 dnl Intel ICC -std=c99, -c99 (deprecated)
364 dnl Solaris -D_STDC_C99=
365 dnl cc's -xc99 option uses linker magic to define the external
366 dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
367 dnl behavior for C library functions. This is not wanted here,
368 dnl because it means that a single module compiled with -xc99
369 dnl alters C runtime behavior for the entire program, not for
370 dnl just the module. Instead, define the (private) symbol
371 dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
372 dnl The resulting compiler passes the test case here, and that's
373 dnl good enough. For more, please see the thread starting at:
374 dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
376 dnl with extended modes being tried first.
377 [[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
381 # _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
382 # ----------------------------------------------------------------
383 # If the C compiler is not in ISO C11 mode by default, try to add an
384 # option to output variable CC to make it so. This macro tries
385 # various options that select ISO C11 on some system or another. It
386 # considers the compiler to be in ISO C11 mode if it handles _Alignas,
387 # _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
388 # duplicate typedefs, and anonymous structures and unions.
389 AC_DEFUN([_AC_PROG_CC_C11],
390 [_AC_C_STD_TRY([c11],
391 [_AC_C_C99_TEST_HEADER[
393 char _Alignas (double) aligned_as_double;
394 char _Alignas (0) no_special_alignment;
395 extern char aligned_as_int;
396 char _Alignas (0) _Alignas (int) aligned_as_int;
401 int_alignment = _Alignof (int),
402 int_array_alignment = _Alignof (int[100]),
403 char_alignment = _Alignof (char)
405 _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
408 int _Noreturn does_not_return (void) { for (;;) continue; }
410 // Check _Static_assert.
411 struct test_static_assert
414 _Static_assert (sizeof (int) <= sizeof (long int),
415 "_Static_assert does not work in struct");
419 // Check UTF-8 literals.
420 #define u8 syntax error!
421 char const utf8_literal[] = u8"happens to be ASCII" "another string";
423 // Check duplicate typedefs.
424 typedef long *long_ptr;
425 typedef long int *long_ptr;
426 typedef long_ptr long_ptr;
428 // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
432 struct { int i; int j; };
433 struct { int k; long int l; } w;
438 [_AC_C_C99_TEST_BODY[
441 _Static_assert ((offsetof (struct anonymous, i)
442 == offsetof (struct anonymous, w.k)),
443 "Anonymous union alignment botch");
446 dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
447 dnl with extended modes being tried first.
449 dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
450 dnl of September 2012) does not pass the C11 test. For now, try extc1x when
451 dnl compiling the C99 test instead, since it enables _Static_assert and
452 dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
453 dnl the C11 test in some future version of IBM XL C, we'll add it here,
454 dnl preferably extc11.
455 [[-std=gnu11]], [$1], [$2])[]dnl
461 # Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
462 # as that'd be incompatible with how Automake redefines AC_PROG_CC. See
463 # <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
464 AU_DEFUN([AC_PROG_CC_C89],
465 [AC_REQUIRE([AC_PROG_CC])],
466 [$0 is obsolete; use AC_PROG_CC]
471 AU_DEFUN([AC_PROG_CC_C99],
472 [AC_REQUIRE([AC_PROG_CC])],
473 [$0 is obsolete; use AC_PROG_CC]
478 AU_DEFUN([AC_PROG_CC_STDC],
479 [AC_REQUIRE([AC_PROG_CC])],
480 [$0 is obsolete; use AC_PROG_CC]
486 # Check if the C compiler supports prototypes, included if it needs
488 AC_DEFUN([AC_C_PROTOTYPES],
489 [AC_REQUIRE([AC_PROG_CC])dnl
490 if test "$ac_prog_cc_stdc" != no; then
491 AC_DEFINE(PROTOTYPES, 1,
492 [Define to 1 if the C compiler supports function prototypes.])
493 AC_DEFINE(__PROTOTYPES, 1,
494 [Define like PROTOTYPES; this can be used by system headers.])
499 # _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
500 # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
501 # ----------------------------------------------------------------
502 # Check whether the C++ compiler accepts features of STANDARD (e.g
503 # `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
504 # and TEST-BODY. If this fails, try again with each compiler option
505 # in the space-separated OPTION-LIST; if one helps, append it to CXX.
506 # If eventually successful, run ACTION-IF-AVAILABLE, else
507 # ACTION-IF-UNAVAILABLE.
508 AC_DEFUN([_AC_CXX_STD_TRY],
509 [AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
511 AC_CACHE_VAL(ac_cv_prog_cxx_$1,
512 [ac_cv_prog_cxx_$1=no
514 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
517 CXX="$ac_save_CXX $ac_arg"
518 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
519 test "x$ac_cv_prog_cxx_$1" != "xno" && break
521 rm -f conftest.$ac_ext
524 ac_prog_cxx_stdcxx_options=
525 case "x$ac_cv_prog_cxx_$1" in
527 AC_MSG_RESULT([none needed]) ;;
529 AC_MSG_RESULT([unsupported]) ;;
531 ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
532 CXX=$CXX$ac_prog_cxx_stdcxx_options
533 AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
536 AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
539 # _AC_CXX_CXX98_TEST_HEADER
540 # -------------------------
541 # A C++ header suitable for testing for CXX98.
542 AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
559 typedef std::vector<std::string> string_vec;
560 typedef std::pair<int,bool> map_value;
561 typedef std::map<std::string,map_value> map_type;
562 typedef std::set<int> set_type;
567 printer(std::ostringstream& os): os(os) {}
568 void operator() (T elem) { os << elem << std::endl; }
570 std::ostringstream& os;
573 ]])# _AC_CXX_CXX98_TEST_HEADER
575 # _AC_CXX_CXX98_TEST_BODY
576 # -----------------------
577 # A C++ body suitable for testing for CXX98, assuming the corresponding header.
578 AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
583 std::string teststr("ASCII text");
584 teststr += " string";
587 test::string_vec testvec;
588 testvec.push_back(teststr);
589 testvec.push_back("foo");
590 testvec.push_back("bar");
591 if (testvec.size() != 3) {
592 throw std::runtime_error("vector size is not 1");
595 // Dump vector into stringstream and obtain string.
596 std::ostringstream os;
597 for (test::string_vec::const_iterator i = testvec.begin();
598 i != testvec.end(); ++i) {
599 if (i + 1 != testvec.end()) {
600 os << teststr << '\n';
603 // Check algorithms work.
604 std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
605 std::string os_out = os.str();
607 // Test pair and map.
608 test::map_type testmap;
609 testmap.insert(std::make_pair(std::string("key"),
610 std::make_pair(53,false)));
613 int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
614 test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
615 std::list<int> testlist(testset.begin(), testset.end());
616 std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
617 } catch (const std::exception& e) {
618 std::cerr << "Caught exception: " << e.what() << std::endl;
621 std::ofstream of("test.txt");
622 of << "Test ASCII text\n" << std::flush;
623 of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
629 # _AC_CXX_CXX11_TEST_HEADER
630 # -------------------------
631 # A C++ header suitable for testing for CXX11.
632 AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
635 #include <functional>
644 typedef std::shared_ptr<std::string> sptr;
645 typedef std::weak_ptr<std::string> wptr;
647 typedef std::tuple<std::string,int,double> tp;
648 typedef std::array<int, 20> int_array;
650 constexpr int get_val() { return 20; }
660 delegate(int n) : n(n) {}
661 delegate(): delegate(2354) {}
663 virtual int getval() { return this->n; };
668 class overridden : public delegate {
670 overridden(int n): delegate(n) {}
671 virtual int getval() override final { return this->n * 2; }
676 nocopy(int i): i(i) {}
678 nocopy(const nocopy&) = delete;
679 nocopy & operator=(const nocopy&) = delete;
684 ]])# _AC_CXX_CXX11_TEST_HEADER
686 # _AC_CXX_CXX11_TEST_BODY
687 # -----------------------
688 # A C++ body suitable for testing for CXX11, assuming the corresponding header.
689 AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
692 // Test auto and decltype
699 for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
702 auto a2 = 48573953.4;
703 auto a3 = "String literal";
705 decltype(a2) a4 = 34895.034;
709 short sa[cxx11test::get_val()] = { 0 };
712 // Test initializer lists
713 cxx11test::testinit il = { 4323, 435234.23544 };
716 // Test range-based for and lambda
717 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
718 for (int &x : array) { x += 23; }
719 std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
722 using cxx11test::sptr;
723 using cxx11test::wptr;
725 sptr sp(new std::string("ASCII string"));
730 cxx11test::tp tuple("test", 54, 45.53434);
731 double d = std::get<2>(tuple);
734 std::tie(s,i,d) = tuple;
737 static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
738 std::string testmatch("Test if this string matches");
739 bool match = std::regex_search(testmatch, filename_regex);
742 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
743 cxx11test::int_array::size_type size = array.size();
746 // Test constructor delegation
747 cxx11test::delegate d1;
748 cxx11test::delegate d2();
749 cxx11test::delegate d3(45);
752 // Test override and final
753 cxx11test::overridden o1(55464);
760 // Test template brackets
761 std::vector<std::pair<int,char*>> v1;
765 char const *utf8 = u8"UTF-8 string \u2500";
766 char16_t const *utf16 = u"UTF-8 string \u2500";
767 char32_t const *utf32 = U"UTF-32 string \u2500";
771 # _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
772 # -------------------------------------------------------------------
774 # If the C++ compiler is not in ISO C++98 mode by default, try to add
775 # an option to output variable CXX to make it so. This macro tries
776 # various options that select ISO C++98 on some system or another. It
777 # considers the compiler to be in ISO C++98 mode if it handles basic
778 # features of the std namespace including: string, containers (list,
779 # map, set, vector), streams (fstreams, iostreams, stringstreams,
780 # iomanip), pair, exceptions and algorithms.
783 AC_DEFUN([_AC_PROG_CXX_CXX98],
784 [_AC_CXX_STD_TRY([cxx98],
785 [_AC_CXX_CXX98_TEST_HEADER],
786 [_AC_CXX_CXX98_TEST_BODY],
788 dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
789 dnl IBM XL C -qlanglvl=extended
791 dnl Intel ICC -std=gnu++98
792 dnl Solaris N/A (default)
793 dnl Tru64 N/A (default, but -std gnu could be used)
794 dnl with extended modes being tried first.
795 [[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
796 ])# _AC_PROG_CXX_CXX98
798 # _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
799 # -------------------------------------------------------------------
800 # If the C++ compiler is not in ISO CXX11 mode by default, try to add
801 # an option to output variable CXX to make it so. This macro tries
802 # various options that select ISO C++11 on some system or another. It
803 # considers the compiler to be in ISO C++11 mode if it handles all the
804 # tests from the C++98 checks, plus the following: Language features
805 # (auto, constexpr, decltype, default/deleted constructors, delegate
806 # constructors, final, initializer lists, lambda functions, nullptr,
807 # override, range-based for loops, template brackets without spaces,
808 # unicode literals) and library features (array, memory (shared_ptr,
809 # weak_ptr), regex and tuple types).
810 AC_DEFUN([_AC_PROG_CXX_CXX11],
811 [_AC_CXX_STD_TRY([cxx11],
812 [_AC_CXX_CXX11_TEST_HEADER
813 _AC_CXX_CXX98_TEST_HEADER],
814 [_AC_CXX_CXX11_TEST_BODY
815 _AC_CXX_CXX98_TEST_BODY],
817 dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
818 dnl IBM XL C -qlanglvl=extended0x
819 dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
821 dnl Intel ICC -std=c++11 -std=c++0x
822 dnl Solaris N/A (no support)
823 dnl Tru64 N/A (no support)
824 dnl with extended modes being tried first.
825 [[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
826 ])# _AC_PROG_CXX_CXX11
829 ])# m4_version_prereq