summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-01-26 21:01:56 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-01-26 21:01:56 +0000
commitda953b9d2264dd06512f07b71d5188e86d33532b (patch)
tree00ecd23fbb81b80e85d604c83cd7abb54e2b68ee /lib
parenta768b3ebec152e5bcce589f2cdd9891254a7796a (diff)
downloadcoreutils-da953b9d2264dd06512f07b71d5188e86d33532b.tar.xz
Sync stdbool from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog5
-rw-r--r--lib/stdbool_.h47
2 files changed, 27 insertions, 25 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 0cfaa577e..b92b19fcc 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ * stdbool_.h: Sync from gnulib.
+ Use signed char with all non-GCC compilers.
+
2006-01-25 Paul Eggert <eggert@cs.ucla.edu>
* stdbool_.h: Merge from gnulib; we still don't quite match exactly,
diff --git a/lib/stdbool_.h b/lib/stdbool_.h
index 1c12c69ca..efa80ba92 100644
--- a/lib/stdbool_.h
+++ b/lib/stdbool_.h
@@ -69,14 +69,7 @@
this, values of type '_Bool' may promote to 'int' or 'unsigned int'
(see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
(see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
- enum; this ensures that '_Bool' promotes to 'int'. This works
- with older GCC versions that do not have a working <stdbool.h>,
- and it makes bool easier to to debug, so we use this with GCC.
-
- This approach into problems on some non-GCC platforms; the simplest
- way to work around them is to ignore any existing definition of
- _Bool and use our own. */
-
+ enum; this ensures that '_Bool' promotes to 'int'. */
#if defined __cplusplus || defined __BEOS__
/* A compiler known to have 'bool'. */
/* If the compiler already has both 'bool' and '_Bool', we can assume they
@@ -85,27 +78,31 @@
typedef bool _Bool;
# endif
#else
-# if @HAVE__BOOL@ || ! defined __GNUC__
- /* The compiler has _Bool, or it is not GCC. Recall that this
- code is used only if <stdbool.h> does not work, so something is
- odd if there is a _Bool. */
-
- /* Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
- the built-in _Bool type is used. See
- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
- With SunPRO C, avoid stupid
- "warning: _Bool is a keyword in ISO C99".
- With IRIX cc, avoid stupid
- "warning(1185): enumerated type mixed with another type".
- In general, there are enough problems with older compilers like
- this that it's safer to avoid their _Bool entirely when
- <stdbool.h> doesn't work. */
+# if !defined __GNUC__
+ /* If @HAVE__BOOL@:
+ Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+ the built-in _Bool type is used. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ Similar bugs are likely with other compilers as well; this file
+ wouldn't be used if <stdbool.h> was working.
+ So we override the _Bool type.
+ If !@HAVE__BOOL@:
+ Need to define _Bool ourselves. As 'signed char' or as an enum type?
+ Use of a typedef, with SunPRO C, leads to a stupid
+ "warning: _Bool is a keyword in ISO C99".
+ Use of an enum type, with IRIX cc, leads to a stupid
+ "warning(1185): enumerated type mixed with another type".
+ The only benefit of the enum type, debuggability, is not important
+ with these compilers. So use 'signed char' and no typedef. */
# define _Bool signed char
enum { false = 0, true = 1 };
# else
+ /* With this compiler, trust the _Bool type if the compiler has it. */
+# if !@HAVE__BOOL@
typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+# endif
# endif
#endif
#define bool _Bool