31
33
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
32
34
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
34
# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
35
# have this macro built-in.
36
# This version of the macro is needed in autoconf <= 2.68.
37
AC_DEFUN([AC_HEADER_STDBOOL],
38
AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
38
39
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
39
40
[ac_cv_header_stdbool_h],
44
"error: bool is not defined"
47
"error: false is not defined"
50
"error: false is not 0"
53
"error: true is not defined"
56
"error: true is not 1"
58
#ifndef __bool_true_false_are_defined
59
"error: __bool_true_false_are_defined is not defined"
62
struct s { _Bool s: 1; _Bool t; } s;
64
char a[true == 1 ? 1 : -1];
65
char b[false == 0 ? 1 : -1];
66
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
67
char d[(bool) 0.5 == true ? 1 : -1];
69
char f[(_Bool) 0.0 == false ? 1 : -1];
71
char h[sizeof (_Bool)];
73
enum { j = false, k = true, l = false * true, m = true * 256 };
75
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
76
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
77
#if defined __xlc__ || defined __GNUC__
78
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
79
reported by James Lemley on 2005-10-05; see
80
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
81
This test is not quite right, since xlc is allowed to
82
reject this program, as the initializer for xlcbug is
83
not one of the forms that C requires support for.
84
However, doing the test right would require a run-time
85
test, and that would make cross-compilation harder.
86
Let us hope that IBM fixes the xlc bug, and also adds
87
support for this kind of constant expression. In the
88
meantime, this test will reject xlc, which is OK, since
89
our stdbool.h substitute should suffice. We also test
90
this with GCC, where it should work, to detect more
91
quickly whether someone messes up the test in the
93
char digs[] = "0123456789";
94
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
96
/* Catch a bug in an HP-UX C compiler. See
97
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
98
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
106
/* Refer to every declared value, to avoid compiler optimizations. */
107
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
108
+ !m + !n + !o + !p + !q + !pq);
46
"error: bool is not defined"
49
"error: false is not defined"
52
"error: false is not 0"
55
"error: true is not defined"
58
"error: true is not 1"
60
#ifndef __bool_true_false_are_defined
61
"error: __bool_true_false_are_defined is not defined"
64
struct s { _Bool s: 1; _Bool t; } s;
66
char a[true == 1 ? 1 : -1];
67
char b[false == 0 ? 1 : -1];
68
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
69
char d[(bool) 0.5 == true ? 1 : -1];
70
/* See body of main program for 'e'. */
71
char f[(_Bool) 0.0 == false ? 1 : -1];
73
char h[sizeof (_Bool)];
75
enum { j = false, k = true, l = false * true, m = true * 256 };
76
/* The following fails for
77
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
79
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
80
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
81
/* Catch a bug in an HP-UX C compiler. See
82
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
83
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
92
/* Refer to every declared value, to avoid compiler optimizations. */
93
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
94
+ !m + !n + !o + !p + !q + !pq);
110
96
[ac_cv_header_stdbool_h=yes],
111
97
[ac_cv_header_stdbool_h=no])])
112
98
AC_CHECK_TYPES([_Bool])
113
if test $ac_cv_header_stdbool_h = yes; then
114
AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])