annotate lib/stdbool.in.h @ 448:5cccf90bf838 3.0 tip

Fixed bug with complex external references generating invalid relocations in the object file
author lost@l-w.ca
date Fri, 05 Nov 2010 22:27:00 -0600
parents b8bf63962a99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
434
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
1 /* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
3
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
6 the Free Software Foundation; either version 3, or (at your option)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
7 any later version.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
8
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
12 GNU General Public License for more details.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
13
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
15 along with this program; if not, write to the Free Software Foundation,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
17
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
18 #ifndef _GL_STDBOOL_H
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
19 #define _GL_STDBOOL_H
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
20
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
21 /* ISO C 99 <stdbool.h> for platforms that lack it. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
22
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
23 /* Usage suggestions:
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
24
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
25 Programs that use <stdbool.h> should be aware of some limitations
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
26 and standards compliance issues.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
27
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
28 Standards compliance:
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
29
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
30 - <stdbool.h> must be #included before 'bool', 'false', 'true'
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
31 can be used.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
32
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
33 - You cannot assume that sizeof (bool) == 1.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
34
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
35 - Programs should not undefine the macros bool, true, and false,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
36 as C99 lists that as an "obsolescent feature".
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
37
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
38 Limitations of this substitute, when used in a C89 environment:
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
39
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
40 - <stdbool.h> must be #included before the '_Bool' type can be used.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
41
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
42 - You cannot assume that _Bool is a typedef; it might be a macro.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
43
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
44 - Bit-fields of type 'bool' are not supported. Portable code
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
45 should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
46
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
47 - In C99, casts and automatic conversions to '_Bool' or 'bool' are
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
48 performed in such a way that every nonzero value gets converted
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
49 to 'true', and zero gets converted to 'false'. This doesn't work
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
50 with this substitute. With this substitute, only the values 0 and 1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
51 give the expected result when converted to _Bool' or 'bool'.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
52
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
53 Also, it is suggested that programs use 'bool' rather than '_Bool';
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
54 this isn't required, but 'bool' is more common. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
55
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
56
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
57 /* 7.16. Boolean type and values */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
58
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
59 /* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
60 definitions below, but temporarily we have to #undef them. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
61 #if defined __BEOS__ && !defined __HAIKU__
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
62 # include <OS.h> /* defines bool but not _Bool */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
63 # undef false
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
64 # undef true
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
65 #endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
66
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
67 /* For the sake of symbolic names in gdb, we define true and false as
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
68 enum constants, not only as macros.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
69 It is tempting to write
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
70 typedef enum { false = 0, true = 1 } _Bool;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
71 so that gdb prints values of type 'bool' symbolically. But if we do
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
72 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
73 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
74 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
75 enum; this ensures that '_Bool' promotes to 'int'. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
76 #if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
77 /* A compiler known to have 'bool'. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
78 /* If the compiler already has both 'bool' and '_Bool', we can assume they
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
79 are the same types. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
80 # if !@HAVE__BOOL@
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
81 typedef bool _Bool;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
82 # endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
83 #else
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
84 # if !defined __GNUC__
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
85 /* If @HAVE__BOOL@:
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
86 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
87 the built-in _Bool type is used. See
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
88 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
89 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
90 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
91 Similar bugs are likely with other compilers as well; this file
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
92 wouldn't be used if <stdbool.h> was working.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
93 So we override the _Bool type.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
94 If !@HAVE__BOOL@:
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
95 Need to define _Bool ourselves. As 'signed char' or as an enum type?
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
96 Use of a typedef, with SunPRO C, leads to a stupid
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
97 "warning: _Bool is a keyword in ISO C99".
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
98 Use of an enum type, with IRIX cc, leads to a stupid
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
99 "warning(1185): enumerated type mixed with another type".
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
100 Even the existence of an enum type, without a typedef,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
101 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
102 The only benefit of the enum, debuggability, is not important
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
103 with these compilers. So use 'signed char' and no enum. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
104 # define _Bool signed char
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
105 # else
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
106 /* With this compiler, trust the _Bool type if the compiler has it. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
107 # if !@HAVE__BOOL@
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
108 typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
109 # endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
110 # endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
111 #endif
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
112 #define bool _Bool
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
113
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
114 /* The other macros must be usable in preprocessor directives. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
115 #define false 0
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
116 #define true 1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
117 #define __bool_true_false_are_defined 1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
118
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
119 #endif /* _GL_STDBOOL_H */