aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/stdbool.in.h51
1 files changed, 31 insertions, 20 deletions
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index ed1f9aa488b..1f8caee4f2d 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -66,24 +66,19 @@
66# undef true 66# undef true
67#endif 67#endif
68 68
69/* For the sake of symbolic names in gdb, we define true and false as 69#ifdef __cplusplus
70 enum constants, not only as macros. 70# define _Bool bool
71 It is tempting to write 71# define bool bool
72 typedef enum { false = 0, true = 1 } _Bool; 72#else
73 so that gdb prints values of type 'bool' symbolically. But if we do 73# if defined __BEOS__ && !defined __HAIKU__
74 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
75 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
76 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
77 enum; this ensures that '_Bool' promotes to 'int'. */
78#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
79 /* A compiler known to have 'bool'. */ 74 /* A compiler known to have 'bool'. */
80 /* If the compiler already has both 'bool' and '_Bool', we can assume they 75 /* If the compiler already has both 'bool' and '_Bool', we can assume they
81 are the same types. */ 76 are the same types. */
82# if !@HAVE__BOOL@ 77# if !@HAVE__BOOL@
83typedef bool _Bool; 78typedef bool _Bool;
84# endif 79# endif
85#else 80# else
86# if !defined __GNUC__ 81# if !defined __GNUC__
87 /* If @HAVE__BOOL@: 82 /* If @HAVE__BOOL@:
88 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when 83 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
89 the built-in _Bool type is used. See 84 the built-in _Bool type is used. See
@@ -103,19 +98,35 @@ typedef bool _Bool;
103 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. 98 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
104 The only benefit of the enum, debuggability, is not important 99 The only benefit of the enum, debuggability, is not important
105 with these compilers. So use 'signed char' and no enum. */ 100 with these compilers. So use 'signed char' and no enum. */
106# define _Bool signed char 101# define _Bool signed char
107# else 102# else
108 /* With this compiler, trust the _Bool type if the compiler has it. */ 103 /* With this compiler, trust the _Bool type if the compiler has it. */
109# if !@HAVE__BOOL@ 104# if !@HAVE__BOOL@
105 /* For the sake of symbolic names in gdb, define true and false as
106 enum constants, not only as macros.
107 It is tempting to write
108 typedef enum { false = 0, true = 1 } _Bool;
109 so that gdb prints values of type 'bool' symbolically. But then
110 values of type '_Bool' might promote to 'int' or 'unsigned int'
111 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
112 (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
113 enum; this ensures that '_Bool' promotes to 'int'. */
110typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; 114typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
115# endif
111# endif 116# endif
112# endif 117# endif
118# define bool _Bool
113#endif 119#endif
114#define bool _Bool
115 120
116/* The other macros must be usable in preprocessor directives. */ 121/* The other macros must be usable in preprocessor directives. */
117#define false 0 122#ifdef __cplusplus
118#define true 1 123# define false false
124# define true true
125#else
126# define false 0
127# define true 1
128#endif
129
119#define __bool_true_false_are_defined 1 130#define __bool_true_false_are_defined 1
120 131
121#endif /* _GL_STDBOOL_H */ 132#endif /* _GL_STDBOOL_H */