1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2001-2017, 2020-2024 Free Software Foundation, Inc.
5 # This file is part of Autoconf. This program is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # Under Section 7 of GPL version 3, you are granted additional
17 # permissions described in the Autoconf Configure Script Exception,
18 # version 3.0, as published by the Free Software Foundation.
20 # You should have received a copy of the GNU General Public License
21 # and a copy of the Autoconf Configure Script Exception along with
22 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
23 # respectively. If not, see <https://www.gnu.org/licenses/> and
24 # <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
26 # Written by David MacKenzie, with help from
27 # Akim Demaille, Paul Eggert,
28 # François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
29 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
34 # 1. Language selection
35 # 2. and routines to produce programs in a given language.
41 # 3. Looking for a compiler
42 # And possibly the associated preprocessor.
43 # 3a. C 3b. C++ 3c. Objective C 3d. Objective C++
45 # 4. Compilers' characteristics.
50 ## ----------------------- ##
51 ## 1a/2a. The C language. ##
52 ## ----------------------- ##
55 # ------------------------ #
56 # 1a. Language selection. #
57 # ------------------------ #
61 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
62 AC_LANG_DEFINE([C], [c], [C], [CC], [],
64 ac_cpp='$CPP $CPPFLAGS'
65 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
66 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
67 ac_compiler_gnu=$ac_cv_c_compiler_gnu
73 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
76 # ------------------------ #
77 # 2a. Producing programs. #
78 # ------------------------ #
81 # AC_LANG_CONFTEST(C)(BODY)
82 # -------------------------
83 # We can't use '#line $LINENO "configure"' here, since
84 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
85 # rejects $LINENO greater than 32767, and some configure scripts
86 # are longer than 32767 lines.
87 m4_define([AC_LANG_CONFTEST(C)],
88 [cat confdefs.h - <<_ACEOF >conftest.$ac_ext
94 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
95 # --------------------------------------
96 m4_define([AC_LANG_PROGRAM(C)],
98 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
99 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
103 dnl Do *not* indent the following line: there may be CPP directives.
104 dnl Don't move the ';' right after for the same reason.
111 # _AC_LANG_IO_PROGRAM(C)
112 # ----------------------
113 # Produce source that performs I/O, necessary for proper
114 # cross-compiler detection.
115 m4_define([_AC_LANG_IO_PROGRAM(C)],
116 [AC_LANG_PROGRAM([@%:@include <stdio.h>],
117 [FILE *f = fopen ("conftest.out", "w");
120 return ferror (f) || fclose (f) != 0;
124 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
125 # -----------------------------------
126 # Avoid conflicting decl of main.
127 m4_define([AC_LANG_CALL(C)],
129 m4_if([$2], [main], ,
130 [/* Override any GCC internal prototype to avoid an error.
131 Use char because int might match the return type of a GCC
132 builtin and then its argument prototype would still apply.
133 The 'extern "C"' is for builds by C++ compilers;
134 although this is not generally supported in C code supporting it here
135 has little cost and some practical benefit (sr 110532). */
139 char $2 (void);])], [return $2 ();])])
142 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
143 # ----------------------------------
144 # Don't include <ctype.h> because on OSF/1 3.0 it includes
145 # <sys/types.h> which includes <sys/select.h> which contains a
146 # prototype for select. Similarly for bzero.
148 # This test used to merely assign f=$1 in main(), but that was
149 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
150 # presumably on the basis that there's no need to do that store if the
151 # program is about to exit. Conversely, the AIX linker optimizes an
152 # unused external declaration that initializes f=$1. So this test
153 # program has both an external initialization of f, and a use of f in
154 # main that affects the exit status.
156 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
158 [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
159 For example, HP-UX 11i <limits.h> declares gettimeofday. */
160 #define $1 innocuous_$1
162 /* System header to define __stub macros and hopefully few prototypes,
163 which can conflict with char $1 (void); below. */
168 /* Override any GCC internal prototype to avoid an error.
169 Use char because int might match the return type of a GCC
170 builtin and then its argument prototype would still apply. */
175 /* The GNU C library defines this for functions which it implements
176 to always fail with ENOSYS. Some functions are actually named
177 something starting with __ and the normal name is an alias. */
178 #if defined __stub_$1 || defined __stub___$1
181 ], [return $1 ();])])
184 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
185 # -------------------------------------------------
186 # Return a program that is valid if EXPRESSION is nonzero.
187 # EXPRESSION must be an integer constant expression.
188 # Be sure to use this array to avoid 'unused' warnings, which are even
189 # errors with '-W error'.
190 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
191 [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
192 test_array @<:@0@:>@ = 0;
193 return test_array @<:@0@:>@;
197 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
198 # -----------------------------------------
199 # We need 'stdio.h' to open a 'FILE' and 'stdlib.h' for 'exit'.
200 # But we include them only after the EXPRESSION has been evaluated.
201 m4_define([AC_LANG_INT_SAVE(C)],
203 static long int longval (void) { return $2; }
204 static unsigned long int ulongval (void) { return $2; }
205 @%:@include <stdio.h>
206 @%:@include <stdlib.h>],
208 FILE *f = fopen ("conftest.val", "w");
213 long int i = longval ();
216 fprintf (f, "%ld", i);
220 unsigned long int i = ulongval ();
223 fprintf (f, "%lu", i);
225 /* Do not output a trailing newline, as this causes \r\n confusion
226 on some platforms. */
227 return ferror (f) || fclose (f) != 0;
232 ## ---------------------- ##
233 ## 1b. The C++ language. ##
234 ## ---------------------- ##
239 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
240 AC_LANG_DEFINE([C++], [cxx], [CXX], [CXX], [C],
242 ac_cpp='$CXXCPP $CPPFLAGS'
243 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
244 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
245 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
249 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
250 # -------------------------------------
251 m4_define([AC_LANG_CALL(C++)],
252 dnl We do not know the function signature of the real $2.
253 dnl Declare it in a namespace so the compiler doesn't recognize it
254 dnl (with, most likely, a clashing prototype); the 'extern "C"' hides
255 dnl the namespace from the linker.
256 dnl Use 'int' for the return type, because some C++ compilers consider
257 dnl 'namespace conftest { extern "C" void main (); }' to be an
258 dnl erroneous redeclaration of ::main, namespace notwithstanding.
259 dnl The logic they're applying could be extended in the future to
260 dnl other built-in extern "C" functions, but let's worry about that
261 dnl when it actually happens.
262 [AC_LANG_PROGRAM([[$1
264 extern "C" int $2 ();
266 [[return conftest::$2 ();]])])
271 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
275 ## ------------------------------ ##
276 ## 1c. The Objective C language. ##
277 ## ------------------------------ ##
280 # AC_LANG(Objective C)
281 # --------------------
282 AC_LANG_DEFINE([Objective C], [objc], [OBJC], [OBJC], [C],
284 ac_cpp='$OBJCPP $CPPFLAGS'
285 ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
286 ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
287 ac_compiler_gnu=$ac_cv_objc_compiler_gnu
293 AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
297 ## -------------------------------- ##
298 ## 1d. The Objective C++ language. ##
299 ## -------------------------------- ##
302 # AC_LANG(Objective C++)
303 # ----------------------
304 AC_LANG_DEFINE([Objective C++], [objcxx], [OBJCXX], [OBJCXX], [C++],
306 ac_cpp='$OBJCXXCPP $CPPFLAGS'
307 ac_compile='$OBJCXX -c $OBJCXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
308 ac_link='$OBJCXX -o conftest$ac_exeext $OBJCXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
309 ac_compiler_gnu=$ac_cv_objcxx_compiler_gnu
314 ## -------------------------------------------- ##
315 ## 3. Looking for Compilers and Preprocessors. ##
316 ## -------------------------------------------- ##
318 # -------------------- #
319 # 3a. The C compiler. #
320 # -------------------- #
323 # _AC_ARG_VAR_CPPFLAGS
324 # --------------------
325 # Document and register CPPFLAGS, which is used by
326 # AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP, OBJCXX, OBJCXXCPP}.
327 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
328 [AC_ARG_VAR([CPPFLAGS],
329 [(Objective) C/C++ preprocessor flags, e.g. -I<include dir>
330 if you have headers in a nonstandard directory <include dir>])])
333 # _AC_ARG_VAR_LDFLAGS
334 # -------------------
335 # Document and register LDFLAGS, which is used by
336 # AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
337 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
338 [AC_ARG_VAR([LDFLAGS],
339 [linker flags, e.g. -L<lib dir> if you have libraries in a
340 nonstandard directory <lib dir>])])
345 # Document and register LIBS, which is used by
346 # AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
347 AC_DEFUN([_AC_ARG_VAR_LIBS],
349 [libraries to pass to the linker, e.g. -l<library>])])
354 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
355 AC_DEFUN([AC_LANG_PREPROC(C)],
356 [AC_REQUIRE([AC_PROG_CPP])])
359 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
360 # -----------------------------------------------
361 # Check if $ac_cpp is a working preprocessor that can flag absent
362 # includes either by the exit status or by warnings.
363 # This macro is for all languages, not only C.
364 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
366 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
368 # Use a header file that comes with gcc, so configuring glibc
369 # with a fresh cross-compiler works.
370 # On the NeXT, cc -E runs the code through the compiler's parser,
371 # not just through cpp. "Syntax error" is here to catch this case.
372 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <limits.h>
375 [# Broken: fails on valid input.
378 # OK, works on sane cases. Now check whether nonexistent headers
379 # can be detected and how.
380 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
381 [# Broken: success on invalid input.
383 [# Passes both tests.
388 # Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped.
389 rm -f conftest.i conftest.err conftest.$ac_ext
390 AS_IF([$ac_preproc_ok], [$1], [$2])
391 ])# _AC_PROG_PREPROC_WORKS_IFELSE
396 # Find a working C preprocessor.
397 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
398 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
399 AN_MAKEVAR([CPP], [AC_PROG_CPP])
400 AN_PROGRAM([cpp], [AC_PROG_CPP])
401 AC_DEFUN([AC_PROG_CPP],
402 [AC_REQUIRE([AC_PROG_CC])dnl
403 AC_ARG_VAR([CPP], [C preprocessor])dnl
404 _AC_ARG_VAR_CPPFLAGS()dnl
406 AC_MSG_CHECKING([how to run the C preprocessor])
407 # On Suns, sometimes $CPP names a directory.
408 if test -n "$CPP" && test -d "$CPP"; then
411 if test -z "$CPP"; then
412 AC_CACHE_VAL([ac_cv_prog_CPP],
414 # Double quotes because $CC needs to be expanded
415 for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
417 _AC_PROG_PREPROC_WORKS_IFELSE([break])
425 AC_MSG_RESULT([$CPP])
426 _AC_PROG_PREPROC_WORKS_IFELSE([],
427 [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
434 # Treat warnings from the preprocessor as errors.
435 AC_DEFUN([AC_PROG_CPP_WERROR],
436 [AC_REQUIRE([AC_PROG_CPP])dnl
437 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
439 # AC_LANG_COMPILER(C)
440 # -------------------
441 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
442 AC_DEFUN([AC_LANG_COMPILER(C)],
443 [AC_REQUIRE([AC_PROG_CC])])
448 # We used to name the cache variable this way.
449 AU_DEFUN([ac_cv_prog_gcc],
450 [ac_cv_c_compiler_gnu])
453 # AC_PROG_CC([COMPILER ...])
454 # --------------------------
455 # COMPILER ... is a space separated list of C compilers to search for.
456 # This just gives the user an opportunity to specify an alternative
457 # search list for the C compiler.
458 AN_MAKEVAR([CC], [AC_PROG_CC])
459 AN_PROGRAM([cc], [AC_PROG_CC])
460 AN_PROGRAM([gcc], [AC_PROG_CC])
461 AC_DEFUN([AC_PROG_CC],
463 AC_ARG_VAR([CC], [C compiler command])dnl
464 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
465 _AC_ARG_VAR_LDFLAGS()dnl
466 _AC_ARG_VAR_LIBS()dnl
467 _AC_ARG_VAR_CPPFLAGS()dnl
469 [AC_CHECK_TOOLS(CC, [$1])],
470 [AC_CHECK_TOOL(CC, gcc)
471 if test -z "$CC"; then
473 dnl AC_CHECK_TOOL(CC, cc)
474 dnl but without the check for a tool without the prefix.
475 dnl Until the check is removed from there, copy the code:
476 if test -n "$ac_tool_prefix"; then
477 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
480 if test -z "$CC"; then
481 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
483 if test -z "$CC"; then
484 AC_CHECK_TOOLS(CC, cl.exe)
486 if test -z "$CC"; then
487 AC_CHECK_TOOL(CC, clang)
491 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
493 # Provide some information about the compiler.
494 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
497 for ac_option in --version -v -V -qversion -version; do
498 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
501 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
502 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
503 _AC_LANG_COMPILER_GNU
504 if test $ac_compiler_gnu = yes; then
510 _AC_PROG_CC_STDC_EDITION
517 # Check whether -g works, even if CFLAGS is set, in case the package
518 # plays around with CFLAGS (such as to build both debugging and normal
519 # versions of a library), tasteless as that idea is.
520 # Don't consider -g to work if it generates warnings when plain compiles don't.
521 m4_define([_AC_PROG_CC_G],
522 [ac_test_CFLAGS=${CFLAGS+y}
523 ac_save_CFLAGS=$CFLAGS
524 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
525 [ac_save_c_werror_flag=$ac_c_werror_flag
529 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
530 [ac_cv_prog_cc_g=yes],
532 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
534 [ac_c_werror_flag=$ac_save_c_werror_flag
536 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
537 [ac_cv_prog_cc_g=yes])])])
538 ac_c_werror_flag=$ac_save_c_werror_flag])
539 if test $ac_test_CFLAGS; then
540 CFLAGS=$ac_save_CFLAGS
541 elif test $ac_cv_prog_cc_g = yes; then
542 if test "$GCC" = yes; then
548 if test "$GCC" = yes; then
559 AC_DEFUN([AC_PROG_CC_C_O],
560 [AC_REQUIRE([AC_PROG_CC])dnl
562 if test "x$CC" != xcc; then
563 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
565 AC_MSG_CHECKING([whether cc understands -c and -o together])
567 set dummy $CC; ac_cc=`AS_ECHO(["$[2]"]) |
568 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
569 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
570 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
571 # Make sure it works both with $CC and with simple cc.
572 # We do the test twice because some compilers refuse to overwrite an
573 # existing .o file with -o, though they will create one.
574 ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
576 if _AC_DO_VAR(ac_try) &&
577 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
579 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
580 if test "x$CC" != xcc; then
581 # Test first that cc exists at all.
582 if _AC_DO_TOKENS(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
583 ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
585 if _AC_DO_VAR(ac_try) &&
586 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
591 # cc exists but doesn't like -o.
592 eval ac_cv_prog_cc_${ac_cc}_c_o=no
597 eval ac_cv_prog_cc_${ac_cc}_c_o=no
599 rm -rf core conftest*
601 if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
605 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
606 [Define to 1 if your C compiler doesn't accept -c and -o together.])
613 # ---------------------- #
614 # 3b. The C++ compiler. #
615 # ---------------------- #
618 # AC_LANG_PREPROC(C++)
619 # --------------------
620 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
621 AC_DEFUN([AC_LANG_PREPROC(C++)],
622 [AC_REQUIRE([AC_PROG_CXXCPP])])
627 # Find a working C++ preprocessor.
628 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
629 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
630 AC_DEFUN([AC_PROG_CXXCPP],
631 [AC_REQUIRE([AC_PROG_CXX])dnl
632 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
633 _AC_ARG_VAR_CPPFLAGS()dnl
635 AC_MSG_CHECKING([how to run the C++ preprocessor])
636 if test -z "$CXXCPP"; then
637 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
639 # Double quotes because $CXX needs to be expanded
640 for CXXCPP in "$CXX -E" cpp /lib/cpp
642 _AC_PROG_PREPROC_WORKS_IFELSE([break])
644 ac_cv_prog_CXXCPP=$CXXCPP
646 CXXCPP=$ac_cv_prog_CXXCPP
648 ac_cv_prog_CXXCPP=$CXXCPP
650 AC_MSG_RESULT([$CXXCPP])
651 _AC_PROG_PREPROC_WORKS_IFELSE([],
652 [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
658 # AC_LANG_COMPILER(C++)
659 # ---------------------
660 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
661 AC_DEFUN([AC_LANG_COMPILER(C++)],
662 [AC_REQUIRE([AC_PROG_CXX])])
667 # We used to name the cache variable this way.
668 AU_DEFUN([ac_cv_prog_gxx],
669 [ac_cv_cxx_compiler_gnu])
672 # AC_PROG_CXX([LIST-OF-COMPILERS])
673 # --------------------------------
674 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
675 # for (if not specified, a default list is used). This just gives the
676 # user an opportunity to specify an alternative search list for the C++
678 # aCC HP-UX C++ compiler much better than 'CC', so test before.
679 # FCC Fujitsu C++ compiler
680 # KCC KAI C++ compiler
682 # xlC_r IBM XL C++ for AIX (with support for reentrant code)
683 # xlC IBM XL C++ for AIX
684 AN_MAKEVAR([CXX], [AC_PROG_CXX])
685 AN_PROGRAM([CC], [AC_PROG_CXX])
686 AN_PROGRAM([c++], [AC_PROG_CXX])
687 AN_PROGRAM([g++], [AC_PROG_CXX])
688 AC_DEFUN([AC_PROG_CXX],
689 [AC_LANG_PUSH(C++)dnl
690 AC_ARG_VAR([CXX], [C++ compiler command])dnl
691 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
692 _AC_ARG_VAR_LDFLAGS()dnl
693 _AC_ARG_VAR_LIBS()dnl
694 _AC_ARG_VAR_CPPFLAGS()dnl
695 _AC_ARG_VAR_PRECIOUS([CCC])dnl
696 if test -z "$CXX"; then
697 if test -n "$CCC"; then
702 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
706 # Provide some information about the compiler.
707 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
710 for ac_option in --version -v -V -qversion; do
711 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
714 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
715 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
716 _AC_LANG_COMPILER_GNU
717 if test $ac_compiler_gnu = yes; then
729 # Check whether -g works, even if CXXFLAGS is set, in case the package
730 # plays around with CXXFLAGS (such as to build both debugging and
731 # normal versions of a library), tasteless as that idea is.
732 # Don't consider -g to work if it generates warnings when plain compiles don't.
733 m4_define([_AC_PROG_CXX_G],
734 [ac_test_CXXFLAGS=${CXXFLAGS+y}
735 ac_save_CXXFLAGS=$CXXFLAGS
736 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
737 [ac_save_cxx_werror_flag=$ac_cxx_werror_flag
738 ac_cxx_werror_flag=yes
741 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
742 [ac_cv_prog_cxx_g=yes],
744 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
746 [ac_cxx_werror_flag=$ac_save_cxx_werror_flag
748 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
749 [ac_cv_prog_cxx_g=yes])])])
750 ac_cxx_werror_flag=$ac_save_cxx_werror_flag])
751 if test $ac_test_CXXFLAGS; then
752 CXXFLAGS=$ac_save_CXXFLAGS
753 elif test $ac_cv_prog_cxx_g = yes; then
754 if test "$GXX" = yes; then
760 if test "$GXX" = yes; then
771 # Test if the C++ compiler accepts the options '-c' and '-o'
772 # simultaneously, and define 'CXX_NO_MINUS_C_MINUS_O' if it does not.
773 AC_DEFUN([AC_PROG_CXX_C_O],
774 [AC_REQUIRE([AC_PROG_CXX])dnl
775 AC_LANG_PUSH([C++])dnl
776 AC_CACHE_CHECK([whether $CXX understands -c and -o together],
777 [ac_cv_prog_cxx_c_o],
778 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
779 # We test twice because some compilers refuse to overwrite an existing
780 # '.o' file with '-o', although they will create one.
781 ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
783 if _AC_DO_VAR(ac_try) &&
784 test -f conftest2.$ac_objext &&
785 _AC_DO_VAR(ac_try); then
786 ac_cv_prog_cxx_c_o=yes
788 ac_cv_prog_cxx_c_o=no
791 if test $ac_cv_prog_cxx_c_o = no; then
792 AC_DEFINE(CXX_NO_MINUS_C_MINUS_O, 1,
793 [Define to 1 if your C++ compiler doesn't accept
794 -c and -o together.])
796 AC_LANG_POP([C++])dnl
801 # ------------------------------ #
802 # 3c. The Objective C compiler. #
803 # ------------------------------ #
806 # AC_LANG_PREPROC(Objective C)
807 # ----------------------------
808 # Find the Objective C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
809 AC_DEFUN([AC_LANG_PREPROC(Objective C)],
810 [AC_REQUIRE([AC_PROG_OBJCPP])])
815 # Find a working Objective C preprocessor.
816 AC_DEFUN([AC_PROG_OBJCPP],
817 [AC_REQUIRE([AC_PROG_OBJC])dnl
818 AC_ARG_VAR([OBJCPP], [Objective C preprocessor])dnl
819 _AC_ARG_VAR_CPPFLAGS()dnl
820 AC_LANG_PUSH(Objective C)dnl
821 AC_MSG_CHECKING([how to run the Objective C preprocessor])
822 if test -z "$OBJCPP"; then
823 AC_CACHE_VAL(ac_cv_prog_OBJCPP,
825 # Double quotes because $OBJC needs to be expanded
826 for OBJCPP in "$OBJC -E" cpp /lib/cpp
828 _AC_PROG_PREPROC_WORKS_IFELSE([break])
830 ac_cv_prog_OBJCPP=$OBJCPP
832 OBJCPP=$ac_cv_prog_OBJCPP
834 ac_cv_prog_OBJCPP=$OBJCPP
836 AC_MSG_RESULT([$OBJCPP])
837 _AC_PROG_PREPROC_WORKS_IFELSE([],
838 [AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])
840 AC_LANG_POP(Objective C)dnl
844 # AC_LANG_COMPILER(Objective C)
845 # -----------------------------
846 # Find the Objective C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
847 AC_DEFUN([AC_LANG_COMPILER(Objective C)],
848 [AC_REQUIRE([AC_PROG_OBJC])])
852 # AC_PROG_OBJC([LIST-OF-COMPILERS])
853 # ---------------------------------
854 # LIST-OF-COMPILERS is a space separated list of Objective C compilers to
855 # search for (if not specified, a default list is used). This just gives
856 # the user an opportunity to specify an alternative search list for the
857 # Objective C compiler.
858 # gobjc GNU Objective-C compiler packaged in EPEL (for systems where gcc
859 # does not support Objective-C)
860 # gcc GNU Objective-C compiler on most systems
861 # objcc StepStone Objective-C compiler (also "standard" name for OBJC)
862 # objc David Stes' POC. If you installed this, you likely want it.
863 # cc Native C compiler (for instance, Apple).
865 AN_MAKEVAR([OBJC], [AC_PROG_OBJC])
866 AN_PROGRAM([objcc], [AC_PROG_OBJC])
867 AN_PROGRAM([objc], [AC_PROG_OBJC])
868 AC_DEFUN([AC_PROG_OBJC],
869 [AC_LANG_PUSH(Objective C)dnl
870 AC_ARG_VAR([OBJC], [Objective C compiler command])dnl
871 AC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl
872 _AC_ARG_VAR_LDFLAGS()dnl
873 _AC_ARG_VAR_LIBS()dnl
874 _AC_ARG_VAR_CPPFLAGS()dnl
875 _AC_ARG_VAR_PRECIOUS([OBJC])dnl
877 [m4_default([$1], [gobjc gcc objcc objc cc CC clang])],
879 # Provide some information about the compiler.
880 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
883 for ac_option in --version -v -V -qversion; do
884 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
887 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
888 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
889 _AC_LANG_COMPILER_GNU
890 if test $ac_compiler_gnu = yes; then
896 AC_LANG_POP(Objective C)dnl
902 # Check whether -g works, even if OBJCFLAGS is set, in case the package
903 # plays around with OBJCFLAGS (such as to build both debugging and
904 # normal versions of a library), tasteless as that idea is.
905 # Don't consider -g to work if it generates warnings when plain compiles don't.
906 m4_define([_AC_PROG_OBJC_G],
907 [ac_test_OBJCFLAGS=${OBJCFLAGS+y}
908 ac_save_OBJCFLAGS=$OBJCFLAGS
909 AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
910 [ac_save_objc_werror_flag=$ac_objc_werror_flag
911 ac_objc_werror_flag=yes
914 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
915 [ac_cv_prog_objc_g=yes],
917 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
919 [ac_objc_werror_flag=$ac_save_objc_werror_flag
921 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
922 [ac_cv_prog_objc_g=yes])])])
923 ac_objc_werror_flag=$ac_save_objc_werror_flag])
924 if test $ac_test_OBJCFLAGS; then
925 OBJCFLAGS=$ac_save_OBJCFLAGS
926 elif test $ac_cv_prog_objc_g = yes; then
927 if test "$GOBJC" = yes; then
933 if test "$GOBJC" = yes; then
943 # -------------------------------- #
944 # 3d. The Objective C++ compiler. #
945 # -------------------------------- #
948 # AC_LANG_PREPROC(Objective C++)
949 # ------------------------------
950 # Find the Objective C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
951 AC_DEFUN([AC_LANG_PREPROC(Objective C++)],
952 [AC_REQUIRE([AC_PROG_OBJCXXCPP])])
957 # Find a working Objective C++ preprocessor.
958 AC_DEFUN([AC_PROG_OBJCXXCPP],
959 [AC_REQUIRE([AC_PROG_OBJCXX])dnl
960 AC_ARG_VAR([OBJCXXCPP], [Objective C++ preprocessor])dnl
961 _AC_ARG_VAR_CPPFLAGS()dnl
962 AC_LANG_PUSH(Objective C++)dnl
963 AC_MSG_CHECKING([how to run the Objective C++ preprocessor])
964 if test -z "$OBJCXXCPP"; then
965 AC_CACHE_VAL(ac_cv_prog_OBJCXXCPP,
967 # Double quotes because $OBJCXX needs to be expanded
968 for OBJCXXCPP in "$OBJCXX -E" cpp /lib/cpp
970 _AC_PROG_PREPROC_WORKS_IFELSE([break])
972 ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
974 OBJCXXCPP=$ac_cv_prog_OBJCXXCPP
976 ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
978 AC_MSG_RESULT([$OBJCXXCPP])
979 _AC_PROG_PREPROC_WORKS_IFELSE([],
980 [AC_MSG_FAILURE([Objective C++ preprocessor "$OBJCXXCPP" fails sanity check])])
981 AC_SUBST(OBJCXXCPP)dnl
982 AC_LANG_POP(Objective C++)dnl
983 ])# AC_PROG_OBJCXXCPP
986 # AC_LANG_COMPILER(Objective C++)
987 # -------------------------------
988 # Find the Objective C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
989 AC_DEFUN([AC_LANG_COMPILER(Objective C++)],
990 [AC_REQUIRE([AC_PROG_OBJCXX])])
994 # AC_PROG_OBJCXX([LIST-OF-COMPILERS])
995 # -----------------------------------
996 # LIST-OF-COMPILERS is a space separated list of Objective C++ compilers to
997 # search for (if not specified, a default list is used). This just gives
998 # the user an opportunity to specify an alternative search list for the
999 # Objective C++ compiler.
1000 # FIXME: this list is pure guesswork
1001 # objc++ StepStone Objective-C++ compiler (also "standard" name for OBJCXX)
1002 # objcxx David Stes' POC. If you installed this, you likely want it.
1003 # c++ Native C++ compiler (for instance, Apple).
1004 # CXX You never know.
1005 AN_MAKEVAR([OBJCXX], [AC_PROG_OBJCXX])
1006 AN_PROGRAM([objcxx], [AC_PROG_OBJCXX])
1007 AC_DEFUN([AC_PROG_OBJCXX],
1008 [AC_LANG_PUSH(Objective C++)dnl
1009 AC_ARG_VAR([OBJCXX], [Objective C++ compiler command])dnl
1010 AC_ARG_VAR([OBJCXXFLAGS], [Objective C++ compiler flags])dnl
1011 _AC_ARG_VAR_LDFLAGS()dnl
1012 _AC_ARG_VAR_LIBS()dnl
1013 _AC_ARG_VAR_CPPFLAGS()dnl
1014 _AC_ARG_VAR_PRECIOUS([OBJCXX])dnl
1015 AC_CHECK_TOOLS(OBJCXX,
1016 [m4_default([$1], [g++ objc++ objcxx c++ CXX])],
1018 # Provide some information about the compiler.
1019 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
1022 for ac_option in --version -v -V -qversion; do
1023 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
1026 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
1027 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
1028 _AC_LANG_COMPILER_GNU
1029 if test $ac_compiler_gnu = yes; then
1035 AC_LANG_POP(Objective C++)dnl
1041 # Check whether -g works, even if OBJCFLAGS is set, in case the package
1042 # plays around with OBJCFLAGS (such as to build both debugging and
1043 # normal versions of a library), tasteless as that idea is.
1044 # Don't consider -g to work if it generates warnings when plain compiles don't.
1045 m4_define([_AC_PROG_OBJCXX_G],
1046 [ac_test_OBJCXXFLAGS=${OBJCXXFLAGS+y}
1047 ac_save_OBJCXXFLAGS=$OBJCXXFLAGS
1048 AC_CACHE_CHECK(whether $OBJCXX accepts -g, ac_cv_prog_objcxx_g,
1049 [ac_save_objcxx_werror_flag=$ac_objcxx_werror_flag
1050 ac_objcxx_werror_flag=yes
1051 ac_cv_prog_objcxx_g=no
1053 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1054 [ac_cv_prog_objcxx_g=yes],
1056 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1058 [ac_objcxx_werror_flag=$ac_save_objcxx_werror_flag
1060 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1061 [ac_cv_prog_objcxx_g=yes])])])
1062 ac_objcxx_werror_flag=$ac_save_objcx_werror_flag])
1063 if test $ac_test_OBJCXXFLAGS; then
1064 OBJCXXFLAGS=$ac_save_OBJCXXFLAGS
1065 elif test $ac_cv_prog_objcxx_g = yes; then
1066 if test "$GOBJCXX" = yes; then
1067 OBJCXXFLAGS="-g -O2"
1072 if test "$GOBJCXX" = yes; then
1078 ])# _AC_PROG_OBJCXX_G
1082 ## ------------------------------- ##
1083 ## 4. Compilers' characteristics. ##
1084 ## ------------------------------- ##
1086 # -------------------------------- #
1087 # 4a. C compiler characteristics. #
1088 # -------------------------------- #
1090 # Fragments of these programs are emitted as shell variables in the
1091 # INIT_PREPARE diversion, because they can get long and we want only
1092 # one copy of each fragment in the generated configure. This also
1093 # makes quoting control a bit easier. Try to avoid using ', however,
1094 # because putting single quotes into a single-quoted shell string is
1095 # awkward (you must write '\'' for each ' you want in the program).
1097 # Warning: to avoid incorrect answers due to unused-variable warnings
1098 # and/or overly aggressive optimizers, each variable (global or not)
1099 # in these programs should be used, and each function should be
1100 # called. Unlike how AC_LANG_PROGRAM(C) usually does it, we declare
1101 # main with its usual two arguments, to give the test fragments some
1102 # convenient non-compile-time-constant values to pass around. In main,
1103 # there is an int variable 'ok' which will eventually become the return
1104 # value; use 'ok |= ...' to consume the results of operations.
1106 # Warning: each test program may only use the headers required to
1107 # exist in the relevant standard's *freestanding* environment, in case
1108 # the C compiler targets such an environment. (Therefore, almost no
1109 # features of the C89/C99/C11/C23 standard *library* are probed. Use
1110 # AC_CHECK_HEADER, AC_CHECK_FUNC, etc. for that.) However, these
1111 # programs are only compiled and not linked, so it is ok to declare
1112 # external functions and then call them without worrying about whether
1113 # they actually exist.
1115 # The C89 freestanding headers are:
1116 # <float.h> <limits.h> <stdarg.h> <stddef.h>
1118 # <iso646.h> <stdbool.h> <stdint.h>
1120 # <stdalign.h> <stdnoreturn.h>
1124 AC_DEFUN([_AC_C_C89_TEST_GLOBALS],
1125 [m4_divert_text([INIT_PREPARE],
1126 [[# Test code for whether the C compiler supports C89 (global declarations)
1127 ac_c_conftest_c89_globals='
1128 /* Do not test the value of __STDC__, because some compilers define it to 0
1129 or do not define it, while otherwise adequately conforming. */
1134 /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */
1135 struct buf { int x; };
1136 struct buf * (*rcsopen) (struct buf *, struct stat *, int);
1137 static char *e (char **p, int i)
1141 static char *f (char * (*g) (char **, int), char **p, ...)
1146 s = g (p, va_arg (v,int));
1151 /* C89 style stringification. */
1152 #define noexpand_stringify(a) #a
1153 const char *stringified = noexpand_stringify(arbitrary+token=sequence);
1155 /* C89 style token pasting. Exercises some of the corner cases that
1156 e.g. old MSVC gets wrong, but not very hard. */
1157 #define noexpand_concat(a,b) a##b
1158 #define expand_concat(a,b) noexpand_concat(a,b)
1163 int *pvA = &expand_concat(v,aye);
1164 int *pvbee = &noexpand_concat(v,bee);
1166 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
1167 function prototypes and stuff, but not \xHH hex character constants.
1168 These do not provoke an error unfortunately, instead are silently treated
1169 as an "x". The following induces an error, until -std is added to get
1170 proper ANSI mode. Curiously \x00 != x always comes out true, for an
1171 array size at least. It is necessary to write \x00 == 0 to get something
1172 that is true only with -std. */
1173 int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
1175 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
1176 inside strings and character constants. */
1177 #define FOO(x) '\''x'\''
1178 int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];
1180 int test (int i, double x);
1181 struct s1 {int (*f) (int a);};
1182 struct s2 {int (*f) (double a);};
1183 int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
1187 AC_DEFUN([_AC_C_C89_TEST_MAIN],
1188 [m4_divert_text([INIT_PREPARE],
1189 [[# Test code for whether the C compiler supports C89 (body of main).
1190 ac_c_conftest_c89_main='
1191 ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
1195 AC_DEFUN([_AC_C_C99_TEST_GLOBALS],
1196 [m4_divert_text([INIT_PREPARE],
1197 [[# Test code for whether the C compiler supports C99 (global declarations)
1198 ac_c_conftest_c99_globals='
1199 /* Does the compiler advertise C99 conformance? */
1200 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
1201 # error "Compiler does not advertise C99 conformance"
1204 // See if C++-style comments work.
1206 #include <stdbool.h>
1207 extern int puts (const char *);
1208 extern int printf (const char *, ...);
1209 extern int dprintf (int, const char *, ...);
1210 extern void *malloc (size_t);
1211 extern void free (void *);
1213 // Check varargs macros. These examples are taken from C99 6.10.3.5.
1214 // dprintf is used instead of fprintf to avoid needing to declare
1216 #define debug(...) dprintf (2, __VA_ARGS__)
1217 #define showlist(...) puts (#__VA_ARGS__)
1218 #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
1220 test_varargs_macros (void)
1225 debug ("X = %d\n", x);
1226 showlist (The first, second, and third items.);
1227 report (x>y, "x is %d but y is %d", x, y);
1230 // Check long long types.
1231 #define BIG64 18446744073709551615ull
1232 #define BIG32 4294967295ul
1233 #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
1235 #error "your preprocessor is broken"
1239 #error "your preprocessor is broken"
1241 static long long int bignum = -9223372036854775807LL;
1242 static unsigned long long int ubignum = BIG64;
1244 struct incomplete_array
1252 const wchar_t *name;
1256 typedef const char *ccp;
1259 test_restrict (ccp restrict text)
1261 // Iterate through items via the restricted pointer.
1262 // Also check for declarations in for loops.
1263 for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
1268 // Check varargs and va_copy.
1270 test_varargs (const char *format, ...)
1273 va_start (args, format);
1275 va_copy (args_copy, args);
1277 const char *str = "";
1285 case '\''s'\'': // string
1286 str = va_arg (args_copy, const char *);
1288 case '\''d'\'': // int
1289 number = va_arg (args_copy, int);
1291 case '\''f'\'': // float
1292 fnumber = va_arg (args_copy, double);
1301 return *str && number && fnumber;
1306 AC_DEFUN([_AC_C_C99_TEST_MAIN],
1307 [m4_divert_text([INIT_PREPARE],
1308 [[# Test code for whether the C compiler supports C99 (body of main).
1309 ac_c_conftest_c99_main='
1311 _Bool success = false;
1312 success |= (argc != 0);
1315 if (test_restrict ("String literal") == 0)
1317 char *restrict newvar = "Another string";
1320 success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
1321 test_varargs_macros ();
1323 // Check flexible array members.
1324 struct incomplete_array *ia =
1325 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
1327 for (int i = 0; i < ia->datasize; ++i)
1328 ia->data[i] = i * 1.234;
1329 // Work around memory leak warnings.
1332 // Check named initializers.
1333 struct named_init ni = {
1335 .name = L"Test wide string",
1336 .average = 543.34343,
1341 // Do not test for VLAs, as some otherwise-conforming compilers lack them.
1342 // C code should instead use __STDC_NO_VLA__; see Autoconf manual.
1344 // work around unused variable warnings
1345 ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
1346 || ni.number != 58);
1350 AC_DEFUN([_AC_C_C11_TEST_GLOBALS],
1351 [m4_divert_text([INIT_PREPARE],
1352 [[# Test code for whether the C compiler supports C11 (global declarations)
1353 ac_c_conftest_c11_globals='
1354 /* Does the compiler advertise C11 conformance? */
1355 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
1356 # error "Compiler does not advertise C11 conformance"
1360 char _Alignas (double) aligned_as_double;
1361 char _Alignas (0) no_special_alignment;
1362 extern char aligned_as_int;
1363 char _Alignas (0) _Alignas (int) aligned_as_int;
1368 int_alignment = _Alignof (int),
1369 int_array_alignment = _Alignof (int[100]),
1370 char_alignment = _Alignof (char)
1372 _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
1375 int _Noreturn does_not_return (void) { for (;;) continue; }
1377 // Check _Static_assert.
1378 struct test_static_assert
1381 _Static_assert (sizeof (int) <= sizeof (long int),
1382 "_Static_assert does not work in struct");
1386 // Check UTF-8 literals.
1387 #define u8 syntax error!
1388 char const utf8_literal[] = u8"happens to be ASCII" "another string";
1390 // Check duplicate typedefs.
1391 typedef long *long_ptr;
1392 typedef long int *long_ptr;
1393 typedef long_ptr long_ptr;
1395 // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
1399 struct { int i; int j; };
1400 struct { int k; long int l; } w;
1407 AC_DEFUN([_AC_C_C11_TEST_MAIN],
1408 [m4_divert_text([INIT_PREPARE],
1409 [[# Test code for whether the C compiler supports C11 (body of main).
1410 ac_c_conftest_c11_main='
1411 _Static_assert ((offsetof (struct anonymous, i)
1412 == offsetof (struct anonymous, w.k)),
1413 "Anonymous union alignment botch");
1420 AC_DEFUN([_AC_C_C23_TEST_GLOBALS],
1421 [m4_divert_text([INIT_PREPARE],
1422 [[# Test code for whether the C compiler supports C23 (global declarations)
1423 ac_c_conftest_c23_globals='
1424 /* Does the compiler advertise conformance to C17 or earlier?
1425 Although GCC 14 does not do that, even with -std=gnu23,
1426 it is close enough, and defines __STDC_VERSION == 202000L. */
1427 #if !defined __STDC_VERSION__ || __STDC_VERSION__ <= 201710L
1428 # error "Compiler advertises conformance to C17 or earlier"
1432 char alignas (double) c23_aligned_as_double;
1433 char alignas (0) c23_no_special_alignment;
1434 extern char c23_aligned_as_int;
1435 char alignas (0) alignas (int) c23_aligned_as_int;
1440 c23_int_alignment = alignof (int),
1441 c23_int_array_alignment = alignof (int[100]),
1442 c23_char_alignment = alignof (char)
1444 static_assert (0 < -alignof (int), "alignof is signed");
1446 int function_with_unnamed_parameter (int) { return 0; }
1448 void c23_noreturn ();
1450 bool use_u8 = !u8"\xFF" == u8'\''x'\'';
1452 bool check_that_bool_works = true | false | !nullptr;
1454 # error "true does not work in #if"
1457 #elifdef __STDC_VERSION__
1459 # error "#elifdef does not work"
1462 #ifndef __has_c_attribute
1463 # error "__has_c_attribute not defined"
1466 #ifndef __has_include
1467 # error "__has_include not defined"
1471 #define FORTY_TWO(x) 42
1472 #define VA_OPT_TEST(r, x, ...) __VA_OPT__ (FORTY_TWO r x))
1473 static_assert (VA_OPT_TEST (LPAREN (), 0, <:-) == 42);
1475 static_assert (0b101010 == 42);
1476 static_assert (0B101010 == 42);
1477 static_assert (0xDEAD'\''BEEF == 3'\''735'\''928'\''559);
1478 static_assert (0.500'\''000'\''000 == 0.5);
1480 enum unsignedish : unsigned int { uione = 1 };
1481 static_assert (0 < -uione);
1484 constexpr nullptr_t null_pointer = nullptr;
1487 static_assert (__STDC_ENDIAN_LITTLE__ != __STDC_ENDIAN_BIG__);
1489 static typeof (1 + 1L) two () { return 2; }
1490 static long int three () { return 3; }
1494 AC_DEFUN([_AC_C_C23_TEST_MAIN],
1495 [m4_divert_text([INIT_PREPARE],
1496 [[# Test code for whether the C compiler supports C23 (body of main).
1497 ac_c_conftest_c23_main='
1499 label_before_declaration:
1502 goto label_before_declaration;
1504 goto label_at_end_of_block;
1505 label_at_end_of_block:
1511 AC_DEFUN([_AC_C_C89_TEST_PROGRAM],
1512 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1513 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1514 m4_divert_text([INIT_PREPARE],
1515 [[# Test code for whether the C compiler supports C89 (complete).
1516 ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
1519 main (int argc, char **argv)
1522 ${ac_c_conftest_c89_main}
1528 AC_DEFUN([_AC_C_C99_TEST_PROGRAM],
1529 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1530 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1531 AC_REQUIRE([_AC_C_C99_TEST_GLOBALS])dnl
1532 AC_REQUIRE([_AC_C_C99_TEST_MAIN])dnl
1533 m4_divert_text([INIT_PREPARE],
1534 [[# Test code for whether the C compiler supports C99 (complete).
1535 ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
1536 ${ac_c_conftest_c99_globals}
1539 main (int argc, char **argv)
1542 ${ac_c_conftest_c89_main}
1543 ${ac_c_conftest_c99_main}
1549 AC_DEFUN([_AC_C_C11_TEST_PROGRAM],
1550 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1551 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1552 AC_REQUIRE([_AC_C_C99_TEST_GLOBALS])dnl
1553 AC_REQUIRE([_AC_C_C99_TEST_MAIN])dnl
1554 AC_REQUIRE([_AC_C_C11_TEST_GLOBALS])dnl
1555 AC_REQUIRE([_AC_C_C11_TEST_MAIN])dnl
1556 m4_divert_text([INIT_PREPARE],
1557 [[# Test code for whether the C compiler supports C11 (complete).
1558 ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
1559 ${ac_c_conftest_c99_globals}
1560 ${ac_c_conftest_c11_globals}
1563 main (int argc, char **argv)
1566 ${ac_c_conftest_c89_main}
1567 ${ac_c_conftest_c99_main}
1568 ${ac_c_conftest_c11_main}
1574 AC_DEFUN([_AC_C_C23_TEST_PROGRAM],
1575 [AC_REQUIRE([_AC_C_C23_TEST_GLOBALS])dnl
1576 AC_REQUIRE([_AC_C_C23_TEST_MAIN])dnl
1577 m4_divert_text([INIT_PREPARE],
1578 [[# Test code for whether the C compiler supports C23 (complete).
1579 ac_c_conftest_c23_program="${ac_c_conftest_c23_globals}
1585 ${ac_c_conftest_c23_main}
1594 # Whitespace-separated list of options that might put the C compiler
1595 # into a mode conforming to ISO C1990 with extensions. Do not try
1596 # "strictly conforming" modes (e.g. gcc's -std=c90); they break some
1597 # systems' header files. If more than one option is needed, put
1598 # shell quotes around the group.
1600 # AIX circa 2003 -qlanglvl=extc89
1601 # old AIX -qlanglvl=ansi
1602 # Ultrix, OSF/1, Tru64 -std
1603 # HP-UX 10.20 and later -Ae
1604 # HP-UX older versions -Aa -D_HPUX_SOURCE
1605 # SVR4 -Xc -D__EXTENSIONS__
1606 m4_define([_AC_C_C89_OPTIONS], [
1611 "-Aa -D_HPUX_SOURCE"
1612 "-Xc -D__EXTENSIONS__"
1618 # Whitespace-separated list of options that might put the C compiler
1619 # into a mode conforming to ISO C1999 with extensions. Do not try
1620 # "strictly conforming" modes (e.g. gcc's -std=c99); they break some
1621 # systems' header files. If more than one option is needed, put
1622 # shell quotes around the group.
1624 # GCC, Clang -std=gnu99
1625 # Intel ICC -std=c99, -c99 (deprecated)
1626 # Note: because -std=c99 puts GCC in strictly conforming mode,
1627 # this option must be tested *after* -std=gnu99.
1630 # IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
1631 # IBM XL C -qlanglvl=extc99 (pre-V12.1)
1633 # Solaris -D_STDC_C99=
1634 # Note: acc's -xc99 option uses linker magic to define the external
1635 # symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
1636 # behavior for C library functions. This is not wanted here,
1637 # because it means that a single module compiled with -xc99 alters
1638 # C runtime behavior for the entire program, not for just the
1639 # module. Instead, define the (private) symbol _STDC_C99, which
1640 # suppresses a bogus failure in <stdbool.h>. The resulting compiler
1641 # passes the test case here, and that's good enough.
1642 # For more, please see the thread starting at:
1643 # https://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
1644 m4_define([_AC_C_C99_OPTIONS], [
1657 # Whitespace-separated list of options that might put the C compiler
1658 # into a mode conforming to ISO C2011 with extensions. Do not try
1659 # "strictly conforming" modes (e.g. gcc's -std=c11); they break some
1660 # systems' header files. If more than one option is needed, put
1661 # shell quotes around the group.
1663 # GCC, Clang -std=gnu11
1666 # For IBM XL C for AIX V16.1 or later, '-std=gnu11' should work if
1667 # the user configured with CC='xlclang'. Otherwise, do not try
1668 # -qlanglvl=extc1x as xlc with IBM XL C V16.1 (the latest version as
1669 # of August 2020) does not pass the C11 test. Instead, try extc1x when
1670 # compiling the C99 test instead, since it enables _Static_assert and
1671 # _Noreturn, which is a win.
1672 m4_define([_AC_C_C11_OPTIONS], [
1679 # Whitespace-separated list of options that might put the C compiler
1680 # into a mode conforming to ISO C 2023 with extensions. Do not try
1681 # "strictly conforming" modes (e.g. gcc's -std=c23); they break some
1682 # systems' header files. If more than one option is needed, put
1683 # shell quotes around the group.
1685 # GCC, Clang -std=gnu23
1686 m4_define([_AC_C_C23_OPTIONS], [
1691 # _AC_PROG_CC_STDC_EDITION_TRY(EDITION)
1692 # -------------------------------------
1693 # Subroutine of _AC_PROG_CC_STDC_EDITION. Not to be called directly.
1695 # Check whether the C compiler accepts features of EDITION of the
1696 # C standard. EDITION should be a two-digit year (e.g. 89, 99, 11, 23).
1697 # (FIXME: Switch to four-digit years for futureproofing.)
1698 # This is done by compiling the test program defined by
1699 # _AC_C_C{EDITION}_TEST_PROGRAM, first with no additional
1700 # command-line options, and then with each of the options
1701 # in the space-separated list defined by _AC_C_C{EDITION}_OPTIONS.
1703 # If we find a way to make the test program compile, set cache variable
1704 # ac_cv_prog_cc_cEDITION to the options required (if any), and add those
1705 # options to $CC. Set shell variable ac_prog_cc_stdc to 'cEDITION',
1706 # and set shell variable ac_cv_prog_cc_stdc to the options required.
1707 # (Neither of these variables is AC_SUBSTed. ac_cv_prog_cc_stdc used
1708 # to be a cache variable and is preserved with this name for backward
1709 # compatibility.) Otherwise, ac_cv_prog_cc_cEDITION is set to 'no'
1710 # and the other variables are not changed.
1712 # If ac_prog_cc_stdc is already set to a value other than 'no',
1713 # the shell code produced by this macro does nothing. This is so
1714 # _AC_PROG_CC_STDC_EDITION can use m4_map to iterate through
1716 AC_DEFUN([_AC_PROG_CC_STDC_EDITION_TRY],
1717 [AC_LANG_ASSERT([C])]dnl
1718 [AC_REQUIRE([_AC_C_C$1_TEST_PROGRAM])]dnl
1719 [AS_IF([test x$ac_prog_cc_stdc = xno],
1720 [AC_MSG_CHECKING([for $CC option to enable C$1 features])
1721 AC_CACHE_VAL([ac_cv_prog_cc_c$1],
1722 [ac_cv_prog_cc_c$1=no
1724 AC_LANG_CONFTEST([AC_LANG_DEFINES_PROVIDED][$][ac_c_conftest_c$1_program])
1725 for ac_arg in '' m4_normalize(m4_defn([_AC_C_C$1_OPTIONS]))
1727 CC="$ac_save_CC $ac_arg"
1728 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_c$1=$ac_arg])
1729 test "x$ac_cv_prog_cc_c$1" != "xno" && break
1731 rm -f conftest.$ac_ext
1733 AS_IF([test "x$ac_cv_prog_cc_c$1" = xno],
1734 [AC_MSG_RESULT([unsupported])],
1735 [AS_IF([test "x$ac_cv_prog_cc_c$1" = x],
1736 [AC_MSG_RESULT([none needed])],
1737 [AC_MSG_RESULT([$ac_cv_prog_cc_c$1])
1738 CC="$CC $ac_cv_prog_cc_c$1"])
1739 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c$1
1740 ac_prog_cc_stdc=c$1])])
1744 # _AC_PROG_CC_STDC_EDITION
1745 # ------------------------
1746 # Detect the most recent edition of the ISO C standard that is
1747 # supported by the C compiler. Add command-line options to $CC, if
1748 # necessary, to enable support for this edition. Set the shell
1749 # variable ac_prog_cc_stdc to indicate the edition.
1750 AC_DEFUN([_AC_PROG_CC_STDC_EDITION],
1752 m4_map([_AC_PROG_CC_STDC_EDITION_TRY], [[23], [11], [99], [89]])])
1755 # _AC_PROG_CC_C89(ACTION-IF-SUPPORTED, ACTION-IF-NOT-SUPPORTED)
1756 # -------------------------------------------------------------
1757 # Obsolete internal macro. No longer used by Autoconf itself, but
1758 # preserved for backward compatibility with pre-December 2020 versions
1759 # of Gnulib's std-gnu11.m4, which replaced the entire definition of
1760 # AC_PROG_CC *except* for this macro. Can be removed once everyone is
1761 # using Autoconf 2.70 and/or a current std-gnu11.m4.
1762 AC_DEFUN([_AC_PROG_CC_C89],
1763 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])]dnl
1764 [AC_REQUIRE([_AC_C_C89_TEST_MAIN])]dnl
1765 [_AC_C_STD_TRY([c89],
1766 [$ac_c_conftest_c89_globals], [$ac_c_conftest_c89_main],
1767 m4_quote(m4_normalize(m4_defn([_AC_C_C89_OPTIONS]))),
1775 # Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
1776 # as that'd be incompatible with how Automake redefines AC_PROG_CC. See
1777 # <https://lists.gnu.org/archive/html/autoconf/2012-10/msg00048.html>.
1778 AU_DEFUN([AC_PROG_CC_C89],
1779 [AC_REQUIRE([AC_PROG_CC])],
1780 [$0 is obsolete; use AC_PROG_CC]
1785 AU_DEFUN([AC_PROG_CC_C99],
1786 [AC_REQUIRE([AC_PROG_CC])],
1787 [$0 is obsolete; use AC_PROG_CC]
1792 AU_DEFUN([AC_PROG_CC_STDC],
1793 [AC_REQUIRE([AC_PROG_CC])],
1794 [$0 is obsolete; use AC_PROG_CC]
1797 # AC_PROG_GCC_TRADITIONAL
1798 # -----------------------
1799 AU_DEFUN([AC_PROG_GCC_TRADITIONAL],
1800 [AC_REQUIRE([AC_PROG_CC])],
1801 [$0 is obsolete; use AC_PROG_CC]
1806 AC_DEFUN([AC_C_BACKSLASH_A],
1808 AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1809 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1814 char buf['\a' == 'a' ? -1 : 1];
1816 return buf[0] != "\a"[0];
1818 [ac_cv_c_backslash_a=yes],
1819 [ac_cv_c_backslash_a=no])])
1820 if test $ac_cv_c_backslash_a = yes; then
1821 AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1822 [Define if backslash-a works in C strings.])
1829 # Has been merged into AC_PROG_CC.
1830 AU_DEFUN([AC_C_CROSS], [])
1833 # AC_C_CHAR_UNSIGNED
1834 # ------------------
1835 AC_DEFUN([AC_C_CHAR_UNSIGNED],
1836 [AH_VERBATIM([__CHAR_UNSIGNED__],
1837 [/* Define to 1 if type 'char' is unsigned and your compiler does not
1838 predefine this macro. */
1839 #ifndef __CHAR_UNSIGNED__
1840 # undef __CHAR_UNSIGNED__
1842 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1843 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
1844 [((char) -1) < 0])],
1845 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
1846 if test $ac_cv_c_char_unsigned = yes; then
1847 AC_DEFINE(__CHAR_UNSIGNED__)
1849 ])# AC_C_CHAR_UNSIGNED
1852 # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN],
1853 # [ACTION-IF-UNIVERSAL])
1854 # -------------------------------------------------------------------------
1855 AC_DEFUN([AC_C_BIGENDIAN],
1856 [AH_VERBATIM([WORDS_BIGENDIAN],
1857 [/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
1858 significant byte first (like Motorola and SPARC, unlike Intel). */
1859 #if defined AC_APPLE_UNIVERSAL_BUILD
1860 # if defined __BIG_ENDIAN__
1861 # define WORDS_BIGENDIAN 1
1864 # ifndef WORDS_BIGENDIAN
1865 # undef WORDS_BIGENDIAN
1868 AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian],
1869 [ac_cv_c_bigendian=unknown
1870 # See if we're dealing with a universal compiler.
1873 [[#ifndef __APPLE_CC__
1874 not a universal capable compiler
1879 # Check for potential -arch flags. It is not universal unless
1880 # there are at least two -arch flags with different values.
1883 for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
1884 if test -n "$ac_prev"; then
1886 i?86 | x86_64 | ppc | ppc64)
1887 if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
1890 ac_cv_c_bigendian=universal
1896 elif test "x$ac_word" = "x-arch"; then
1900 if test $ac_cv_c_bigendian = unknown; then
1901 # See if sys/param.h defines the BYTE_ORDER macro.
1904 [[#include <sys/types.h>
1905 #include <sys/param.h>
1907 [[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\
1908 && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\
1913 [# It does; now see whether it defined to BIG_ENDIAN or not.
1916 [[#include <sys/types.h>
1917 #include <sys/param.h>
1919 [[#if BYTE_ORDER != BIG_ENDIAN
1923 [ac_cv_c_bigendian=yes],
1924 [ac_cv_c_bigendian=no])])
1926 if test $ac_cv_c_bigendian = unknown; then
1927 # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
1930 [[#include <limits.h>
1932 [[#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
1936 [# It does; now see whether it defined to _BIG_ENDIAN or not.
1939 [[#include <limits.h>
1941 [[#ifndef _BIG_ENDIAN
1945 [ac_cv_c_bigendian=yes],
1946 [ac_cv_c_bigendian=no])])
1948 if test $ac_cv_c_bigendian = unknown; then
1949 # Compile a test program.
1951 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1953 /* Are we little or big endian? From Harbison&Steele. */
1957 char c[sizeof (long int)];
1960 return u.c[sizeof (long int) - 1] == 1;
1962 [ac_cv_c_bigendian=no],
1963 [ac_cv_c_bigendian=yes],
1964 [# Try to guess by grepping values from an object file.
1967 [[unsigned short int ascii_mm[] =
1968 { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
1969 unsigned short int ascii_ii[] =
1970 { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
1971 int use_ascii (int i) {
1972 return ascii_mm[i] + ascii_ii[i];
1974 unsigned short int ebcdic_ii[] =
1975 { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
1976 unsigned short int ebcdic_mm[] =
1977 { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
1978 int use_ebcdic (int i) {
1979 return ebcdic_mm[i] + ebcdic_ii[i];
1982 main (int argc, char **argv)
1984 /* Intimidate the compiler so that it does not
1985 optimize the arrays away. */
1987 ascii_mm[1] = *p++; ebcdic_mm[1] = *p++;
1988 ascii_ii[1] = *p++; ebcdic_ii[1] = *p++;
1989 return use_ascii (argc) == use_ebcdic (*p);
1991 [if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then
1992 ac_cv_c_bigendian=yes
1994 if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then
1995 if test "$ac_cv_c_bigendian" = unknown; then
1996 ac_cv_c_bigendian=no
1998 # finding both strings is unlikely to happen, but who knows?
1999 ac_cv_c_bigendian=unknown
2003 case $ac_cv_c_bigendian in #(
2006 [AC_DEFINE([WORDS_BIGENDIAN], 1)]);; #(
2010 dnl Note that AC_APPLE_UNIVERSAL_BUILD sorts less than WORDS_BIGENDIAN;
2011 dnl this is a necessity for proper config header operation. Warn if
2012 dnl the user did not specify a config header but is relying on the
2013 dnl default behavior for universal builds.
2015 [AC_CONFIG_COMMANDS_PRE([m4_ifset([AH_HEADER], [],
2016 [m4_warn([obsolete],
2017 [AC_C_BIGENDIAN should be used with AC_CONFIG_HEADERS])])])dnl
2018 AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1,
2019 [Define if building universal (internal helper macro)])])
2023 [AC_MSG_ERROR([unknown endianness
2024 presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
2031 # Define HAVE_C__GENERIC if _Generic works, a la C11.
2032 AN_IDENTIFIER([_Generic], [AC_C__GENERIC])
2033 AC_DEFUN([AC_C__GENERIC],
2034 [AC_CACHE_CHECK([for _Generic], ac_cv_c__Generic,
2038 main (int argc, char **argv)
2040 int a = _Generic (argc, int: argc = 1);
2041 int *b = &_Generic (argc, default: argc);
2042 char ***c = _Generic (argv, int: argc, default: argv ? &argv : 0);
2043 _Generic (1 ? 0 : b, int: a, default: b) = &argc;
2044 _Generic (a = 1, default: a) = 3;
2048 [ac_cv_c__Generic=yes],
2049 [ac_cv_c__Generic=no])])
2050 if test $ac_cv_c__Generic = yes; then
2051 AC_DEFINE([HAVE_C__GENERIC], 1,
2052 [Define to 1 if C11-style _Generic works.])
2058 # Do nothing if the compiler accepts the inline keyword.
2059 # Otherwise define inline to __inline__ or __inline if one of those work,
2060 # otherwise define inline to be empty.
2062 # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
2063 # inline function, only builtin types.
2065 AN_IDENTIFIER([inline], [AC_C_INLINE])
2066 AC_DEFUN([AC_C_INLINE],
2067 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
2069 for ac_kw in inline __inline__ __inline; do
2070 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2071 [#ifndef __cplusplus
2073 static $ac_kw foo_t static_foo (void) {return 0; }
2074 $ac_kw foo_t foo (void) {return 0; }
2077 [ac_cv_c_inline=$ac_kw])
2078 test "$ac_cv_c_inline" != no && break
2081 AH_VERBATIM([inline],
2082 [/* Define to '__inline__' or '__inline' if that's what the C compiler
2083 calls it, or to nothing if 'inline' is not supported under any name. */
2087 case $ac_cv_c_inline in
2090 case $ac_cv_c_inline in
2092 *) ac_val=$ac_cv_c_inline;;
2094 cat >>confdefs.h <<_ACEOF
2096 #define inline $ac_val
2106 AC_DEFUN([AC_C_CONST],
2107 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
2108 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
2111 /* Ultrix mips cc rejects this sort of thing. */
2112 typedef int charset[2];
2113 const charset cs = { 0, 0 };
2114 /* SunOS 4.1.1 cc rejects this. */
2115 char const *const *pcpcc;
2117 /* NEC SVR4.0.2 mips cc rejects this. */
2118 struct point {int x, y;};
2119 static struct point const zero = {0,0};
2120 /* IBM XL C 1.02.0.0 rejects this.
2121 It does not let you subtract one const X* pointer from another in
2122 an arm of an if-expression whose if-part is not a constant
2124 const char *g = "string";
2125 pcpcc = &g + (g ? g-g : 0);
2126 /* HPUX 7.0 cc rejects these. */
2128 ppc = (char**) pcpcc;
2129 pcpcc = (char const *const *) ppc;
2130 { /* SCO 3.2v4 cc rejects this sort of thing. */
2133 char const *s = 0 ? (char *) 0 : (char const *) 0;
2138 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
2140 const int *foo = &x[0];
2143 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
2144 typedef const int *iptr;
2148 { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying
2149 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
2150 struct s { int j; const int *ap[3]; } bx;
2151 struct s *b = &bx; b->j = 5;
2153 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
2157 return !cs[0] && !zero.x;
2160 [ac_cv_c_const=yes],
2161 [ac_cv_c_const=no])])
2162 if test $ac_cv_c_const = no; then
2164 [Define to empty if 'const' does not conform to ANSI C.])
2171 # based on acx_restrict.m4, from the GNU Autoconf Macro Archive
2173 # Determine whether the C/C++ compiler supports the "restrict" keyword
2174 # introduced in ANSI C99, or an equivalent. Define "restrict" to the alternate
2175 # spelling, if any; these are more likely to work in both C and C++ compilers of
2176 # the same family, and in the presence of varying compiler options. If only
2177 # plain "restrict" works, do nothing. Here are some variants:
2178 # - GCC supports both __restrict and __restrict__
2179 # - older DEC Alpha C compilers support only __restrict
2180 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
2181 # Otherwise, define "restrict" to be empty.
2182 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
2183 AC_DEFUN([AC_C_RESTRICT],
2184 [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
2185 [ac_cv_c_restrict=no
2186 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
2187 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
2188 # Put 'restrict' last, because C++ lacks it.
2189 for ac_kw in __restrict__ __restrict _Restrict restrict; do
2192 [[typedef int *int_ptr;
2193 int foo (int_ptr $ac_kw ip) { return ip[0]; }
2194 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
2195 int bar (int ip[$ac_kw]) { return ip[0]; }
2200 return foo (t) + bar (t);
2202 [ac_cv_c_restrict=$ac_kw])
2203 test "$ac_cv_c_restrict" != no && break
2206 AH_VERBATIM([restrict],
2207 [/* Define to the equivalent of the C99 'restrict' keyword, or to
2208 nothing if this is not supported. Do not define if restrict is
2209 supported only directly. */
2211 /* Work around a bug in older versions of Sun C++, which did not
2212 #define __restrict__ or support _Restrict or __restrict__
2213 even though the corresponding Sun C compiler ended up with
2214 "#define restrict _Restrict" or "#define restrict __restrict__"
2215 in the previous line. This workaround can be removed once
2216 we assume Oracle Developer Studio 12.5 (2016) or later. */
2217 #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
2219 # define __restrict__
2221 case $ac_cv_c_restrict in
2223 no) AC_DEFINE([restrict], []) ;;
2224 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
2231 # Note that, unlike const, #defining volatile to be the empty string can
2232 # actually turn a correct program into an incorrect one, since removing
2233 # uses of volatile actually grants the compiler permission to perform
2234 # optimizations that could break the user's code. So, do not #define
2235 # volatile away unless it is really necessary to allow the user's code
2236 # to compile cleanly. Benign compiler failures should be tolerated.
2237 AC_DEFUN([AC_C_VOLATILE],
2238 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
2239 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
2241 int * volatile y = (int *) 0;
2242 return !x && !y;])],
2243 [ac_cv_c_volatile=yes],
2244 [ac_cv_c_volatile=no])])
2245 if test $ac_cv_c_volatile = no; then
2246 AC_DEFINE(volatile,,
2247 [Define to empty if the keyword 'volatile' does not work.
2248 Warning: valid code using 'volatile' can become incorrect
2249 without. Disable with care.])
2256 # Checks if '#' can be used to glue strings together at the CPP level.
2257 # Defines HAVE_STRINGIZE if positive.
2258 # Obsolete - new code should assume C89 compliance.
2259 AC_DEFUN([AC_C_STRINGIZE],
2260 [AC_REQUIRE([AC_PROG_CC])
2261 if test "$ac_prog_cc_stdc" != no; then
2262 AC_DEFINE(HAVE_STRINGIZE, 1,
2263 [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
2270 # Check if the C compiler supports prototypes.
2271 # Obsolete - new code should assume C89 compliance.
2272 AC_DEFUN([AC_C_PROTOTYPES],
2273 [AC_REQUIRE([AC_PROG_CC])dnl
2274 if test "$ac_prog_cc_stdc" != no; then
2275 AC_DEFINE(PROTOTYPES, 1,
2276 [Define to 1 if the C compiler supports function prototypes.])
2277 AC_DEFINE(__PROTOTYPES, 1,
2278 [Define like PROTOTYPES; this can be used by system headers.])
2283 # AC_C_FLEXIBLE_ARRAY_MEMBER
2284 # --------------------------
2285 # Check whether the C compiler supports flexible array members.
2286 AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
2288 AC_CACHE_CHECK([for flexible array members],
2292 [[#include <stdlib.h>
2295 struct s { int n; double d[]; };]],
2296 [[int m = getchar ();
2297 struct s *p = (struct s *) malloc (offsetof (struct s, d)
2298 + m * sizeof (double));
2300 m = p->d != (double *) NULL;
2303 [ac_cv_c_flexmember=yes],
2304 [ac_cv_c_flexmember=no])])
2305 if test $ac_cv_c_flexmember = yes; then
2306 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [],
2307 [Define to nothing if C supports flexible array members, and to
2308 1 if it does not. That way, with a declaration like 'struct s
2309 { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack
2310 can be used with pre-C99 compilers.
2311 When computing the size of such an object, don't use 'sizeof (struct s)'
2312 as it overestimates the size. Use 'offsetof (struct s, d)' instead.
2313 Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with
2314 MSVC and with C++ compilers.])
2316 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1)
2323 # Check whether the C compiler supports variable-length arrays.
2324 AC_DEFUN([AC_C_VARARRAYS],
2326 AC_CACHE_CHECK([for variable-length arrays],
2328 [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2329 [[ #ifndef __STDC_NO_VLA__
2330 #error __STDC_NO_VLA__ not defined
2333 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
2336 [[/* Test for VLA support. This test is partly inspired
2337 from examples in the C standard. Use at least two VLA
2338 functions to detect the GCC 3.4.3 bug described in:
2339 https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
2341 #ifdef __STDC_NO_VLA__
2346 int fvla (int m, int C[m][m]);
2349 simple (int count, int all[static count])
2351 return all[count - 1];
2355 fvla (int m, int C[m][m])
2357 typedef int VLA[m][m];
2360 static int (*q)[m] = &B;
2362 return C && &x[0][0] == &D[0] && &D[0] == s[0];
2366 [ac_cv_c_vararrays=yes],
2367 [ac_cv_c_vararrays=no])])])
2368 if test "$ac_cv_c_vararrays" = yes; then
2369 dnl This is for compatibility with Autoconf 2.61-2.69.
2370 AC_DEFINE([HAVE_C_VARARRAYS], 1,
2371 [Define to 1 if C supports variable-length arrays.])
2372 elif test "$ac_cv_c_vararrays" = no; then
2373 AC_DEFINE([__STDC_NO_VLA__], 1,
2374 [Define to 1 if C does not support variable-length arrays, and
2375 if the compiler does not already define this.])
2382 # Check if the C compiler supports GCC's typeof syntax.
2383 # The test case provokes incompatibilities in the Sun C compilers
2384 # (both Solaris 8 and Solaris 10).
2385 AC_DEFUN([AC_C_TYPEOF],
2387 AC_CACHE_CHECK([for typeof syntax and keyword spelling], ac_cv_c_typeof,
2389 for ac_kw in typeof __typeof__ no; do
2390 test $ac_kw = no && break
2391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
2396 + ! (($ac_kw (value))
2397 (($ac_kw (value)) 0 < ($ac_kw (value)) -1
2398 ? ($ac_kw (value)) - 1
2399 : ~ (~ ($ac_kw (value)) 0
2400 << sizeof ($ac_kw (value)))))]; }
2403 (! ((void) ((ac__typeof_type_ *) 0), 0));
2405 [ac_cv_c_typeof=$ac_kw])
2406 test $ac_cv_c_typeof != no && break
2408 if test $ac_cv_c_typeof != no; then
2409 AC_DEFINE([HAVE_TYPEOF], 1,
2410 [Define to 1 if typeof works with your compiler.])
2411 if test $ac_cv_c_typeof != typeof; then
2412 AC_DEFINE_UNQUOTED([typeof], [$ac_cv_c_typeof],
2413 [Define to __typeof__ if your compiler spells it that way.])
2421 # Expands to some language dependent source code for testing the presence of
2423 AC_DEFUN([_AC_LANG_OPENMP],
2424 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
2426 # _AC_LANG_OPENMP(C)
2427 # ------------------
2428 m4_define([_AC_LANG_OPENMP(C)],
2431 #error "OpenMP not supported"
2434 int main (void) { return omp_get_num_threads (); }
2437 # _AC_LANG_OPENMP(C++)
2438 # --------------------
2439 m4_copy([_AC_LANG_OPENMP(C)], [_AC_LANG_OPENMP(C++)])
2441 # _AC_LANG_OPENMP(Fortran 77)
2442 # ---------------------------
2443 m4_define([_AC_LANG_OPENMP(Fortran 77)],
2449 call omp_set_num_threads(2)
2453 # _AC_LANG_OPENMP(Fortran)
2454 # ------------------------
2455 m4_copy([_AC_LANG_OPENMP(Fortran 77)], [_AC_LANG_OPENMP(Fortran)])
2459 # Check which options need to be passed to the C compiler to support OpenMP.
2460 # Set the OPENMP_CFLAGS / OPENMP_CXXFLAGS / OPENMP_FFLAGS variable to these
2462 # The options are necessary at compile time (so the #pragmas are understood)
2463 # and at link time (so the appropriate library is linked with).
2464 # This macro takes care to not produce redundant options if $CC $CFLAGS already
2467 # For each candidate option, we do a compile test first, then a link test;
2468 # if the compile test succeeds but the link test fails, that means we have
2469 # found the correct option but it doesn't work because the libraries are
2470 # broken. (This can happen, for instance, with SunPRO C and a bad combination
2471 # of operating system patches.)
2473 # Several of the options in our candidate list can be misinterpreted by
2474 # compilers that don't use them to activate OpenMP support; for example,
2475 # many compilers understand "-openmp" to mean "write output to a file
2476 # named 'penmp'" rather than "enable OpenMP". We can't completely avoid
2477 # the possibility of clobbering files named 'penmp' or 'mp' in configure's
2478 # working directory; therefore, this macro will bomb out if any such file
2479 # already exists when it's invoked.
2480 AC_DEFUN([AC_OPENMP],
2481 [AC_REQUIRE([_AC_OPENMP_SAFE_WD])]dnl
2482 [AC_ARG_ENABLE([openmp],
2483 [AS_HELP_STRING([--disable-openmp], [do not use OpenMP])])]dnl
2485 OPENMP_[]_AC_LANG_PREFIX[]FLAGS=
2486 if test "$enable_openmp" != no; then
2487 AC_CACHE_CHECK([for $[]_AC_CC[] option to support OpenMP],
2488 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp],
2489 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='not found'
2490 dnl Try these flags:
2491 dnl (on by default) ''
2492 dnl GCC >= 4.2 -fopenmp
2493 dnl SunPRO C -xopenmp
2495 dnl SGI C, PGI C -mp
2496 dnl Tru64 Compaq C -omp
2497 dnl IBM XL C (AIX, Linux) -qsmp=omp
2500 dnl Lahey Fortran (Linux) --openmp
2501 for ac_option in '' -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \
2502 -Popenmp --openmp; do
2504 ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
2505 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
2506 AC_COMPILE_IFELSE([_AC_LANG_OPENMP],
2507 [AC_LINK_IFELSE([_AC_LANG_OPENMP],
2508 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option],
2509 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'])])
2510 _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
2512 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'not found'; then
2516 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" = 'not found'; then
2517 ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'
2518 elif test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" = ''; then
2519 ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'
2521 dnl _AC_OPENMP_SAFE_WD checked that these files did not exist before we
2522 dnl started probing for OpenMP support, so if they exist now, they were
2523 dnl created by the probe loop and it's safe to delete them.
2525 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'unsupported' && \
2526 test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'none needed'; then
2527 OPENMP_[]_AC_LANG_PREFIX[]FLAGS="$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp"
2530 AC_SUBST([OPENMP_]_AC_LANG_PREFIX[FLAGS])
2533 # _AC_OPENMP_SAFE_WD
2534 # ------------------
2535 # AC_REQUIREd by AC_OPENMP. Checks both at autoconf time and at
2536 # configure time for files that AC_OPENMP clobbers.
2537 AC_DEFUN([_AC_OPENMP_SAFE_WD],
2538 [m4_syscmd([test ! -e penmp && test ! -e mp])]dnl
2539 [m4_if(sysval, [0], [], [m4_fatal(m4_normalize(
2540 [AC_OPENMP clobbers files named 'mp' and 'penmp'.
2541 To use AC_OPENMP you must not have either of these files
2542 at the top level of your source tree.]))])]dnl
2543 [if test -e penmp || test -e mp; then
2544 AC_MSG_ERROR(m4_normalize(
2545 [AC@&t@_OPENMP clobbers files named 'mp' and 'penmp'.
2546 Aborting configure because one of these files already exists.]))