autoconf-patches
[Top][All Lists]
Advanced

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

Re: Bison uses two different 'bool' flavors


From: Akim Demaille
Subject: Re: Bison uses two different 'bool' flavors
Date: 23 Oct 2002 09:26:58 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| > From: Akim Demaille <address@hidden>
| > Date: 22 Oct 2002 14:33:53 +0200
| > 
| > Nevertheless I have a question: is it normal that it fails on my
| > machine?
| 
| I'm a bit surprised, but not completely surprised.  There are a lot
| of broken <stdbool.h>s out there, and perhaps you have one.  Which
| version of GCC are you using?  What does your stdbool.h look like?

Bingo!  On my machine the default compiler is still the old 2.95.4.
Now if I specify the compiler:

| /tmp % ./configure CC=gcc-3.2                                     nostromo 
9:15
| checking for gcc... gcc-3.2
| checking for C compiler default output... a.out
| checking whether the C compiler works... yes
| checking whether we are cross compiling... no
| checking for suffix of executables... 
| checking for suffix of object files... o
| checking whether we are using the GNU C compiler... yes
| checking whether gcc-3.2 accepts -g... yes
| checking for gcc-3.2 option to accept ANSI C... none needed
| checking for stdbool.h that conforms to C99... yes
| configure: creating ./config.status
| /tmp % ./configure CC=gcc-3.1                                     nostromo 
9:16
| checking for gcc... gcc-3.1
| checking for C compiler default output... a.out
| checking whether the C compiler works... yes
| checking whether we are cross compiling... no
| checking for suffix of executables... 
| checking for suffix of object files... o
| checking whether we are using the GNU C compiler... yes
| checking whether gcc-3.1 accepts -g... yes
| checking for gcc-3.1 option to accept ANSI C... none needed
| checking for stdbool.h that conforms to C99... yes
| configure: creating ./config.status
| /tmp % ./configure CC=gcc-3.0                                     nostromo 
9:16
| checking for gcc... gcc-3.0
| checking for C compiler default output... a.out
| checking whether the C compiler works... yes
| checking whether we are cross compiling... no
| checking for suffix of executables... 
| checking for suffix of object files... o
| checking whether we are using the GNU C compiler... yes
| checking whether gcc-3.0 accepts -g... yes
| checking for gcc-3.0 option to accept ANSI C... none needed
| checking for stdbool.h that conforms to C99... yes
| configure: creating ./config.status

All the gcc 3.x are ok.


| > +Your @file{system.h} should contain the following code:
| > +
| > address@hidden
| > +#if HAVE_STDBOOL_H
| > +# include <stdbool.h>
| > +#else
| > +typedef enum {false = 0, true = 1} bool;
| > +#endif
| > address@hidden verbatim
| 
| I'm not sure that this is a good recommendation, actually, as the
| "#else" part doesn't define symbols that conform to C99.  I realize
| that's how coreutils does it but on 2nd thought perhaps gettext has a
| better model.  Something like this instead:
| 
| #if HAVE_STDBOOL_H
| # include <stdbool.h>
| #else
| # if ! HAVE__BOOL
| #  ifdef __cplusplus
| typedef bool _Bool;
| #  else
| typedef unsigned char _Bool;
| #  endif
| # endif
| # define bool _Bool
| # define false 0
| # define true 1
| # define __bool_true_false_are_defined 1
| #endif
| 
| I realize that this will require some changes to both Autoconf and its
| documentation, though (as well as to Bison, coreutils, etc).  Perhaps
| if I get some free time...

I took care of this the following way.  I don't think it is urgent to
update the other packages that will be able to use 2.55.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/autoconf/headers.m4 (AC_HEADER_STDBOOL): Also look for the
        type _Bool.
        Fix a typo.
        * doc/autoconf.texi (Particular Headers): Adjust according to Paul
        Eggert's recommandations.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.692
diff -u -u -r1.692 autoconf.texi
--- doc/autoconf.texi 22 Oct 2002 12:34:21 -0000 1.692
+++ doc/autoconf.texi 23 Oct 2002 07:26:05 -0000
@@ -4285,14 +4285,24 @@
 @acindex HEADER_STDBOOL
 @cvindex HAVE_STDBOOL_H
 If @file{stdbool.h} exists and is conformant to C99, define
address@hidden to 1.  Your @file{system.h} should contain the
-following code:
address@hidden to 1.  To fulfill the C99 requirements, your
address@hidden should contain the following code:
 
 @verbatim
 #if HAVE_STDBOOL_H
 # include <stdbool.h>
 #else
-typedef enum {false = 0, true = 1} bool;
+# if ! HAVE__BOOL
+#  ifdef __cplusplus
+typedef bool _Bool;
+#  else
+typedef unsigned char _Bool;
+#  endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
 #endif
 @end verbatim
 @end defmac
Index: lib/autoconf/headers.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v
retrieving revision 1.25
diff -u -u -r1.25 headers.m4
--- lib/autoconf/headers.m4 22 Oct 2002 12:34:22 -0000 1.25
+++ lib/autoconf/headers.m4 23 Oct 2002 07:26:05 -0000
@@ -509,7 +509,7 @@
 # error false is not 0
 #endif
 #ifndef true
-# error false is not defined
+# error true is not defined
 #endif
 #if true != 1
 # error true is not 1
@@ -533,6 +533,7 @@
       [[ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ]])],
       [ac_cv_header_stdbool_h=yes],
       [ac_cv_header_stdbool_h=no])])
+AC_CHECK_TYPES([_Bool])
 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






reply via email to

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