summaryrefslogtreecommitdiffstats
path: root/gl/stdbool.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stdbool.in.h')
-rw-r--r--gl/stdbool.in.h56
1 files changed, 33 insertions, 23 deletions
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
index 574c281..7c15772 100644
--- a/gl/stdbool.in.h
+++ b/gl/stdbool.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#ifndef _GL_STDBOOL_H 17#ifndef _GL_STDBOOL_H
19#define _GL_STDBOOL_H 18#define _GL_STDBOOL_H
@@ -67,24 +66,19 @@
67# undef true 66# undef true
68#endif 67#endif
69 68
70/* For the sake of symbolic names in gdb, we define true and false as 69#ifdef __cplusplus
71 enum constants, not only as macros. 70# define _Bool bool
72 It is tempting to write 71# define bool bool
73 typedef enum { false = 0, true = 1 } _Bool; 72#else
74 so that gdb prints values of type 'bool' symbolically. But if we do 73# if defined __BEOS__ && !defined __HAIKU__
75 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
76 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
77 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
78 enum; this ensures that '_Bool' promotes to 'int'. */
79#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
80 /* A compiler known to have 'bool'. */ 74 /* A compiler known to have 'bool'. */
81 /* 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
82 are the same types. */ 76 are the same types. */
83# if !@HAVE__BOOL@ 77# if !@HAVE__BOOL@
84typedef bool _Bool; 78typedef bool _Bool;
85# endif 79# endif
86#else 80# else
87# if !defined __GNUC__ 81# if !defined __GNUC__
88 /* If @HAVE__BOOL@: 82 /* If @HAVE__BOOL@:
89 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
90 the built-in _Bool type is used. See 84 the built-in _Bool type is used. See
@@ -104,19 +98,35 @@ typedef bool _Bool;
104 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. 98 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
105 The only benefit of the enum, debuggability, is not important 99 The only benefit of the enum, debuggability, is not important
106 with these compilers. So use 'signed char' and no enum. */ 100 with these compilers. So use 'signed char' and no enum. */
107# define _Bool signed char 101# define _Bool signed char
108# else 102# else
109 /* 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. */
110# 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'. */
111typedef 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
112# endif 116# endif
113# endif 117# endif
118# define bool _Bool
114#endif 119#endif
115#define bool _Bool
116 120
117/* The other macros must be usable in preprocessor directives. */ 121/* The other macros must be usable in preprocessor directives. */
118#define false 0 122#ifdef __cplusplus
119#define true 1 123# define false false
124# define true true
125#else
126# define false 0
127# define true 1
128#endif
129
120#define __bool_true_false_are_defined 1 130#define __bool_true_false_are_defined 1
121 131
122#endif /* _GL_STDBOOL_H */ 132#endif /* _GL_STDBOOL_H */