1 # Copyright © 2023 Nick Bowler
3 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 # This is free software: you are free to do what the fuck you want to.
5 # There is NO WARRANTY, to the extent permitted by law.
7 # DX_C_FOR_DECLARATIONS
9 # Probe whether for-loop declarations are accepted by the C compiler,
10 # as some pre-C99 implementations do have them. If supported, the cache
11 # variable dx_cv_have_for_decls is set to "yes" and the HAVE_FOR_DECLS
12 # macro is defined to 1.
14 # We skip the test (and define the macro unconditionally) if Autoconf
15 # has previously determined that the C compiler supports C99 or a newer
16 # standard, since the C99 test program checks this. However, autoconf-2.70
17 # has a broken check which indicates C99 compatibility for C89 compilers,
18 # so on this version we still do the check if C99 support is indicated.
20 # Annoyingly, autoconf-2.71 removed the assignment of ac_cv_prog_cc_c99,
21 # even though this was actual documented behaviour...
22 AC_DEFUN([DX_C_FOR_DECLARATIONS],
23 [AS_CASE([${ac_cv_prog_cc_c99-no}/${ac_prog_cc_stdc-no}],
25 [_DX_IF_AC270_C99_BUG([|*/c99])])],
26 [AC_CACHE_CHECK([if $CC supports for-loop declarations],
27 [dx_cv_have_for_decls],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [for (int i; i = 1;) return i;])],
29 [dx_cv_have_for_decls=yes], [dx_cv_have_for_decls=no])])],
30 [dx_cv_have_for_decls=yes])
31 AS_CASE([$dx_cv_have_for_decls],
32 [yes], [AC_DEFINE([HAVE_FOR_DECLS], [1],
33 [Define to 1 if the C compiler supports for-loop declarations.])])])
35 m4_define([_DX_IF_AC270_C99_BUG], [m4_ifdef([_AC_PROG_CC_C99],
36 [m4_bmatch(m4_defn([_AC_PROG_CC_C99]),
37 [_AC_C_STD_TRY.\[c99\], *\[ac_c_conftest_c89_program\]],