autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdbool macro, take 2


From: Bonzini
Subject: Re: stdbool macro, take 2
Date: Thu, 08 Nov 2001 21:34:19 +0100

> So AC_HEADER_STDBOOL should remove any preexisting stdbool.h before
> doing any tests that depend on stdbool.h.

Fixed.

> I don't see why this would be needed.  `make distclean' can just
> remove stdbool.h unconditionally.

Right.

> Can't you use ac_cv_header_stdbool_h for this purpose?

ac_cv_header_stdbool_h was just yes/no -- but of course it can be used
for it.  STDBOOL_H was just a relic of the GNU gettext test, so let's
remove it.

> There's no reason to index STAT_MACROS_BROKEN here.

I had noted that after posting :-(

> If you use this macro, you should also add
> @address@hidden/stdbool.h} to the list of files you remove in
> @code{distclean} targets.

Ok.

> bool a1[false || !true ? -1 : 1];
> #if !defined false || !true || !defined bool
> int a2[-1];
> #endif

Ok again (though I liked my version more...)

> ac_file=m4_default([$2], .)/stdbool.h

You never end learning m4sugar'isms.

> The generated file should contain a copyright notice; otherwise the
> file is not free.  I suggest appending the following text here:

Fixed in this patch.  I also wonder if it's good to turn the
AC_CONFIG_COMMANDS line to

        AC_CONFIG_COMMANDS(m4_ifelse([$2], , , [$2]/)stdbool.h, [

Do you gurus know which one integrates better with Automake?

> One last thing: you need to sign papers for Autoconf for us to accept
> this contribution, as it's nontrivial.  I'll send you the forms if you
> don't have them already.

I'll send assign.changes tomorrow.

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       Thu Nov  8 21:19:58 2001
@@ -3996,6 +3996,19 @@
 @end defmac
 
 
address@hidden AC_HEADER_STDBOOL (@var{path})
address@hidden HEADER_STDBOOL
+If @file{stdbool.h} is absent or does not work correctly, create a
+file @address@hidden/stdbool.h} (default @file{./stdbool.h})
+that does work. This macro invokes @code{AC_CONFIG_COMMANDS} so it
+is an instantiating macro; see @ref{Configuration Actions}.
+
+If you use this macro, you should also add
address@hidden@var{directory}/stdbool.h} to the list of files you remove in
address@hidden targets.
address@hidden 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 Thu Nov  8 21:26:23 2001
@@ -395,6 +395,67 @@
 ])# AC_HEADER_STAT
 
 
+# AC_HEADER_STDBOOL
+# -----------------
+AC_DEFUN([AC_HEADER_STDBOOL], [
+AC_CACHE_CHECK(for a working stdbool.h, ac_cv_header_stdbool_h, [
+  ac_file=m4_default([$2], .)/stdbool.h
+  rm -f $ac_file
+  AC_TRY_COMPILE([#include <stdbool.h>
+bool a1[false || !true ? -1 : 1];
+#if !defined false || !true || !defined bool
+int a2[-1];
+#endif
+], [], ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
+
+AC_CONFIG_COMMANDS(stdbool.h, [
+  ac_file=m4_default([$2], .)/stdbool.h
+  rm -f $ac_file
+  if test $ac_cv_header_stdbool_h = no; then
+    echo config.status: creating $ac_file
+    cat > $ac_file << \EOF_STDBOOL_H
+/* ISO C 99 <stdbool.h> for platforms that lack it.  
+   7.16. Boolean type and values
+ 
+   Written by Bruno Haible <address@hidden>, 2001.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copying and distribution of this stdbool.h file, with or without
+   modification, are permitted provided the copyright notice and this
+   notice are preserved.  */
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+/* Everybody seems to #define false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#ifdef false
+# undef false
+#endif
+#ifdef true
+# 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
+  ],
+  [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

[Prev in Thread] Current Thread [Next in Thread]