summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-02-04 20:38:07 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2011-02-04 20:40:11 -0800
commit46acbee4f8cb63d6656d2efd2025e6f99ee77e81 (patch)
tree7464a4a7a578eeaadca19de505d81406c19a5aaf /lib
parentce7ebea4e74d1e152f1ec6e5a44e3b1c0ca9c7a2 (diff)
downloadautoconf-46acbee4f8cb63d6656d2efd2025e6f99ee77e81.tar.gz
autoconf: new macro AC_HEADER_CHECK_STDBOOL
* NEWS: Document this. * doc/autoconf.texi (Particular Headers): Likewise. In example, don't assume a 'system.h' exists. * lib/autoconf/headers.m4 (AC_CHECK_HEADER_STDBOOL): New macro. Use it with AN_IDENTIFIER, since it's less heavyweight. Reindent to match gnulib, since that's a bit nicer. (AC_HEADER_STDBOOL): Reimplement in terms of it.
Diffstat (limited to 'lib')
-rw-r--r--lib/autoconf/headers.m4135
1 files changed, 72 insertions, 63 deletions
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 75bdfeff..4b028321 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -591,72 +591,81 @@ fi
])# AC_HEADER_STAT
-# AC_HEADER_STDBOOL
+# AC_CHECK_HEADER_STDBOOL
# -----------------
# Check for stdbool.h that conforms to C99.
-AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
-AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
-AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
-AC_DEFUN([AC_HEADER_STDBOOL],
-[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
- [ac_cv_header_stdbool_h],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
- [[
-#include <stdbool.h>
-#ifndef bool
- "error: bool is not defined"
-#endif
-#ifndef false
- "error: false is not defined"
-#endif
-#if false
- "error: false is not 0"
-#endif
-#ifndef true
- "error: true is not defined"
-#endif
-#if true != 1
- "error: true is not 1"
-#endif
-#ifndef __bool_true_false_are_defined
- "error: __bool_true_false_are_defined is not defined"
-#endif
+AN_IDENTIFIER([bool], [AC_CHECK_HEADER_STDBOOL])
+AN_IDENTIFIER([true], [AC_CHECK_HEADER_STDBOOL])
+AN_IDENTIFIER([false],[AC_CHECK_HEADER_STDBOOL])
+AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
+ [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+ [ac_cv_header_stdbool_h],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: true is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
+
+ struct s { _Bool s: 1; _Bool t; } s;
+
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) 0.5 == true ? 1 : -1];
+ /* See body of main program for 'e'. */
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ /* The following fails for
+ HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+ ]],
+ [[
+ bool e = &s;
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ + !m + !n + !o + !p + !q + !pq);
+ ]])],
+ [ac_cv_header_stdbool_h=yes],
+ [ac_cv_header_stdbool_h=no])])
+ AC_CHECK_TYPES([_Bool])
+])# AC_CHECK_HEADER_STDBOOL
+
- struct s { _Bool s: 1; _Bool t; } s;
-
- char a[true == 1 ? 1 : -1];
- char b[false == 0 ? 1 : -1];
- char c[__bool_true_false_are_defined == 1 ? 1 : -1];
- char d[(bool) 0.5 == true ? 1 : -1];
- /* See body of main program for 'e'. */
- char f[(_Bool) 0.0 == false ? 1 : -1];
- char g[true];
- char h[sizeof (_Bool)];
- char i[sizeof s.t];
- enum { j = false, k = true, l = false * true, m = true * 256 };
- /* The following fails for
- HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
- _Bool n[m];
- char o[sizeof n == m * sizeof n[0] ? 1 : -1];
- char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
- /* Catch a bug in an HP-UX C compiler. See
- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
- */
- _Bool q = true;
- _Bool *pq = &q;
- ]],
- [[
- bool e = &s;
- *pq |= q;
- *pq |= ! q;
- /* Refer to every declared value, to avoid compiler optimizations. */
- return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
- + !m + !n + !o + !p + !q + !pq);
- ]])],
- [ac_cv_header_stdbool_h=yes],
- [ac_cv_header_stdbool_h=no])])
-AC_CHECK_TYPES([_Bool])
+# AC_HEADER_STDBOOL
+# -----------------
+# Define HAVE_STDBOOL_H if tdbool.h that conforms to C99.
+AC_DEFUN([AC_HEADER_STDBOOL],
+[AC_CHECK_HEADER_STDBOOL
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
fi