summaryrefslogtreecommitdiffstats
path: root/lib/stdbool_.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdbool_.h')
-rw-r--r--lib/stdbool_.h105
1 files changed, 0 insertions, 105 deletions
diff --git a/lib/stdbool_.h b/lib/stdbool_.h
deleted file mode 100644
index 7cd2da84..00000000
--- a/lib/stdbool_.h
+++ /dev/null
@@ -1,105 +0,0 @@
1/* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
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,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18#ifndef _STDBOOL_H
19#define _STDBOOL_H
20
21/* ISO C 99 <stdbool.h> for platforms that lack it. */
22
23/* Usage suggestions:
24
25 Programs that use <stdbool.h> should be aware of some limitations
26 and standards compliance issues.
27
28 Standards compliance:
29
30 - <stdbool.h> must be #included before 'bool', 'false', 'true'
31 can be used.
32
33 - You cannot assume that sizeof (bool) == 1.
34
35 - Programs should not undefine the macros bool, true, and false,
36 as C99 lists that as an "obsolescent feature".
37
38 Limitations of this substitute, when used in a C89 environment:
39
40 - <stdbool.h> must be #included before the '_Bool' type can be used.
41
42 - You cannot assume that _Bool is a typedef; it might be a macro.
43
44 - In C99, casts and automatic conversions to '_Bool' or 'bool' are
45 performed in such a way that every nonzero value gets converted
46 to 'true', and zero gets converted to 'false'. This doesn't work
47 with this substitute. With this substitute, only the values 0 and 1
48 give the expected result when converted to _Bool' or 'bool'.
49
50 Also, it is suggested that programs use 'bool' rather than '_Bool';
51 this isn't required, but 'bool' is more common. */
52
53
54/* 7.16. Boolean type and values */
55
56/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
57 definitions below, which is OK. */
58#ifdef __BEOS__
59# include <OS.h> /* defines bool but not _Bool */
60#endif
61
62/* C++ and BeOS have a reliable bool (and _Bool, if it exists).
63 Otherwise, since this file is being compiled, the system
64 <stdbool.h> is not reliable so assume that the system _Bool is not
65 reliable either. Under that assumption, it is tempting to write
66
67 typedef enum { false, true } _Bool;
68
69 so that gdb prints values of type 'bool' symbolically. But if we do
70 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
71 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
72 (see ISO C 99 6.3.1.1.(2)). We could instead try this:
73
74 typedef enum { _Bool_dummy = -1, false, true } _Bool;
75
76 as the negative value ensures that '_Bool' promotes to 'int'.
77 However, this runs into some other problems. First, Sun's C
78 compiler when (__SUNPRO_C < 0x550 || __STDC__ == 1) issues a stupid
79 "warning: _Bool is a keyword in ISO C99". Second, IBM's AIX cc
80 compiler 6.0.0.0 (and presumably other versions) mishandles
81 subscripts involving _Bool (effectively, _Bool promotes to unsigned
82 int in this case), and we need to redefine _Bool in that case.
83 Third, HP-UX 10.20's C compiler lacks <stdbool.h> but has _Bool and
84 mishandles comparisons of _Bool to int (it promotes _Bool to
85 unsigned int).
86
87 The simplest way to work around these problems is to ignore any
88 existing definition of _Bool and use our own. */
89
90#if defined __cplusplus || defined __BEOS__
91# if !@HAVE__BOOL@
92typedef bool _Bool;
93# endif
94#else
95# define _Bool signed char
96#endif
97
98#define bool _Bool
99
100/* The other macros must be usable in preprocessor directives. */
101#define false 0
102#define true 1
103#define __bool_true_false_are_defined 1
104
105#endif /* _STDBOOL_H */