1 /* This file is generated via a rule in Makefile.am from the
2 * ../lib/stdbool_.h.in file.
4 * *** DO NOT EDIT THIS FILE DIRECTLY ***
6 * Edit ../lib/stdbool_.h instead.
8 /* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
9 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
28 /* ISO C 99 <stdbool.h> for platforms that lack it. */
32 Programs that use <stdbool.h> should be aware of some limitations
33 and standards compliance issues.
37 - <stdbool.h> must be #included before 'bool', 'false', 'true'
40 - You cannot assume that sizeof (bool) == 1.
42 - Programs should not undefine the macros bool, true, and false,
43 as C99 lists that as an "obsolescent feature".
45 Limitations of this substitute, when used in a C89 environment:
47 - <stdbool.h> must be #included before the '_Bool' type can be used.
49 - You cannot assume that _Bool is a typedef; it might be a macro.
51 - In C99, casts and automatic conversions to '_Bool' or 'bool' are
52 performed in such a way that every nonzero value gets converted
53 to 'true', and zero gets converted to 'false'. This doesn't work
54 with this substitute. With this substitute, only the values 0 and 1
55 give the expected result when converted to _Bool' or 'bool'.
57 Also, it is suggested that programs use 'bool' rather than '_Bool';
58 this isn't required, but 'bool' is more common. */
61 /* 7.16. Boolean type and values */
63 /* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
64 definitions below, but temporarily we have to #undef them. */
66 # include <OS.h> /* defines bool but not _Bool */
71 /* For the sake of symbolic names in gdb, we define true and false as
72 enum constants, not only as macros.
73 It is tempting to write
74 typedef enum { false = 0, true = 1 } _Bool;
75 so that gdb prints values of type 'bool' symbolically. But if we do
76 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
77 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
78 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
79 enum; this ensures that '_Bool' promotes to 'int'. */
80 #if !(defined __cplusplus || defined __BEOS__)
82 # if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)
83 /* Avoid stupid "warning: _Bool is a keyword in ISO C99". */
84 # define _Bool signed char
85 enum { false = 0, true = 1 };
87 typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
95 /* The other macros must be usable in preprocessor directives. */
98 #define __bool_true_false_are_defined 1
100 #endif /* _STDBOOL_H */