1 # Check for stdbool.h that conforms to C99.
3 dnl Copyright (C) 2002-2005 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Prepare for substituting <stdbool.h> if it is not supported.
10 AC_DEFUN([AM_STDBOOL_H],
12 AC_REQUIRE([AC_HEADER_STDBOOL])
14 # Define two additional variables used in the Makefile substitution.
16 if test "$ac_cv_header_stdbool_h" = yes; then
23 if test "$ac_cv_type__Bool" = yes; then
28 AC_SUBST([HAVE__BOOL])
31 # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
32 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.
37 AC_DEFUN([AC_HEADER_STDBOOL],
38 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
39 [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];
79 /* Refer to every declared value, to avoid compiler optimizations. */
80 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
83 [ac_cv_header_stdbool_h=yes],
84 [ac_cv_header_stdbool_h=no])])
85 AC_CHECK_TYPES([_Bool])
86 if test $ac_cv_header_stdbool_h = yes; then
87 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])