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