Here is a macro to test for stdbool.h; since it is a standard header
I think it belongs in autoconf rather than in some macro archive.

The patch is against 2.52f

Paolo
diff -r -U3 old/doc/autoconf.texi new/doc/autoconf.texi
--- old/doc/autoconf.texi       Fri Nov  2 17:10:56 2001
+++ new/doc/autoconf.texi       Wed Nov  7 14:20:10 2001
@@ -3996,6 +3996,15 @@
 @end defmac
 
 
+@defmac AC_HEADER_STDBOOL (@var{path})
+@acindex HEADER_STDBOOL
+@acindex STAT_MACROS_BROKEN
+If the @file{stdbool.h} header is present and works correctly,
+do nothing.  Else create a @file{stdbool.h} file in the given
+path (the default being the current directory).
+@end defmac
+
+
 @defmac AC_HEADER_STDC
 @acindex HEADER_STDC
 @cvindex STDC_HEADERS
diff -r -U3 old/lib/autoconf/headers.m4 new/lib/autoconf/headers.m4
--- old/lib/autoconf/headers.m4 Wed Oct 10 15:08:59 2001
+++ new/lib/autoconf/headers.m4 Wed Nov  7 14:35:55 2001
@@ -395,6 +395,68 @@
 ])# AC_HEADER_STAT
 
 
+# AC_HEADER_STDBOOL
+# -----------------
+AC_DEFUN([AC_HEADER_STDBOOL], [
+dnl gcc 2.95.2 has an <stdbool.h> for which both 'true' and 'false' evaluate
+dnl to 0 in preprocessor expressions.
+AC_CACHE_CHECK(for a working stdbool.h, ac_cv_header_stdbool_h, [
+  AC_TRY_COMPILE([#include <stdbool.h>
+#if false
+int A[-1];
+#endif
+#define b -1
+#if true
+#undef b
+#define b 1
+#endif
+int B[b];
+], [], ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
+
+if test $ac_cv_header_stdbool_h = yes; then
+  STDBOOL_H=''
+else
+  m4_if([$1], , STDBOOL_H=stdbool.h, STDBOOL_H=[$2]/stdbool.h)
+fi
+
+AC_CONFIG_COMMANDS([stdbool.h], [
+  if test $ac_cv_header_stdbool_h = no; then
+    echo config.status: creating $STDBOOL_H
+    cat > $STDBOOL_H <<\EOF_STDBOOL_H
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */
+/* 7.16. Boolean type and values */
+/* Written by Bruno Haible <[EMAIL PROTECTED]>, 2001. */
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#ifdef __BEOS__
+# undef false
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, define _Bool as an enum type.  */
+#ifndef __cplusplus
+typedef enum { false = 0, true = 1 } _Bool;
+#else
+typedef bool _Bool;
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives.  */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H */
+EOF_STDBOOL_H
+  fi],
+  [STDBOOL_H="$STDBOOL_H"
+   ac_cv_header_stdbool_h=$ac_cv_header_stdbool_h])
+])# AC_HEADER_STDBOOL 
+
+
 # AC_HEADER_STDC
 # --------------
 AC_DEFUN([AC_HEADER_STDC],

Reply via email to