bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] stdbool_.h bug breaks coreutils CVS sort on Alpha GCC 2


From: Bruno Haible
Subject: Re: [Bug-gnulib] stdbool_.h bug breaks coreutils CVS sort on Alpha GCC 2.95.4
Date: Thu, 7 Aug 2003 22:52:22 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> I don't see how this proposal would
> address your objection.  Even with the #if conditional, a GNU program
> still couldn't #undef _Bool, since the code still wouldn't work using
> the Forte compiler.

OK, I didn't express my point clearly.

What I don't like is to make <stdbool.h> worse on _all_ platforms just
because one compiler has a problem with it. In the beginning we started
with an <stdbool.h> which
  1. prints 'bool' variables well in gdb,
  2. uses standard typedef to define the type.
Then 1 compiler (gcc) comes across, and we drop feature (1) for all platforms.
Then 1 compiler (Solaris cc) comes across, and we drop feature (2) for all
platforms.

I prefer to keep things working as best as possible, depending on the
compiler, So here's my proposal to care about these 2 particular compilers.

Bruno


*** m4/ChangeLog        7 Aug 2003 10:49:28 -0000       1.469
--- m4/ChangeLog        7 Aug 2003 20:43:40 -0000
***************
*** 1,5 ****
--- 1,9 ----
  2003-08-07  Bruno Haible  <address@hidden>
  
+       * stdbool.m4 (AM_STDBOOL_H): Also test whether enum types are signed.
+ 
+ 2003-08-07  Bruno Haible  <address@hidden>
+ 
        * getndelim2.m4 (gl_GETNDELIM2): Use AC_LIBOBJ(getndelim2). This makes
        the module 'getndelim2' compatible with the module 'getline'.
  
*** m4/stdbool.m4       9 Jan 2003 13:35:14 -0000       1.3
--- m4/stdbool.m4       7 Aug 2003 20:43:40 -0000
***************
*** 23,29 ****
  [
    AC_REQUIRE([AC_HEADER_STDBOOL])
  
!   # Define two additional variables used in the Makefile substitution.
  
    if test "$ac_cv_header_stdbool_h" = yes; then
      STDBOOL_H=''
--- 23,29 ----
  [
    AC_REQUIRE([AC_HEADER_STDBOOL])
  
!   # Define three additional variables used in the Makefile substitution.
  
    if test "$ac_cv_header_stdbool_h" = yes; then
      STDBOOL_H=''
***************
*** 38,43 ****
--- 38,55 ----
      HAVE__BOOL=0
    fi
    AC_SUBST([HAVE__BOOL])
+ 
+   AC_CACHE_CHECK([whether enum types are signed], ac_cv_c_enum_signed,
+     [AC_TRY_COMPILE([
+          typedef enum { fls = 0, tru = 1 } bol;
+          typedef int array[1 - 2*(0 < -1 - (bol)fls)];
+        ], [], [ac_cv_c_enum_signed=yes], [ac_cv_c_enum_signed=no])])
+   if test "$ac_cv_c_enum_signed"; then
+     HAVE_SIGNED_ENUM=1
+   else
+     HAVE_SIGNED_ENUM=0
+   fi
+   AC_SUBST([HAVE_SIGNED_ENUM])
  ])
  
  # This macro is only needed in autoconf <= 2.54.  Newer versions of autoconf
*** lib/ChangeLog       6 Aug 2003 04:34:47 -0000       1.523
--- lib/ChangeLog       7 Aug 2003 20:43:41 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2003-08-07  Bruno Haible  <address@hidden>
+ 
+       * stdbool_.h (_Bool): Make the last change conditional on
+       HAVE_SIGNED_ENUM. Use #define for _Bool when using the Solaris
+       C compiler.
+ 
  2003-08-05  Paul Eggert  <address@hidden>
  
        * bumpalloc.h: Remove.
*** lib/stdbool_.h      5 Aug 2003 19:29:51 -0000       1.3
--- lib/stdbool_.h      7 Aug 2003 20:43:41 -0000
***************
*** 39,46 ****
--- 39,55 ----
     (see ISO C 99 6.3.1.1.(2)).  */
  #ifndef __cplusplus
  # if address@hidden@
+ #  if @HAVE_SIGNED_ENUM@
+ typedef enum { false = 0, true = 1 } _Bool;
+ #  else
  enum { false = 0, true = 1 };
+ #   if defined __sun && !defined __GNUC__
+      /* Avoid stupid "warning: _Bool is a keyword in ISO C99".  */
+ #    define _Bool signed char
+ #   else
  typedef signed char _Bool;
+ #   endif
+ #  endif
  # endif
  #else
  typedef bool _Bool;





reply via email to

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