0334cd9fcffe5603bca1673b2663dc410aa98a2b
[gnulib.git] / lib / stdbool_.h
1 /* Copyright (C) 2001, 2002, 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18 #ifndef _STDBOOL_H
19 #define _STDBOOL_H
20
21 /* ISO C 99 <stdbool.h> for platforms that lack it.  */
22
23 /* 7.16. Boolean type and values */
24
25 /* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
26    definitions below, but temporarily we have to #undef them.  */
27 #ifdef __BEOS__
28 # undef false
29 # undef true
30 #endif
31
32 /* For the sake of symbolic names in gdb, define true and false as
33    enum constants.  However, do not define _Bool as the enum type,
34    since the enum type might be compatible with unsigned int, whereas
35    _Bool must promote to int.  */
36 #ifndef __cplusplus
37 # if !@HAVE__BOOL@
38 enum { false = 0, true = 1 };
39 typedef signed char _Bool;
40 # endif
41 #else
42 typedef bool _Bool;
43 #endif
44 #define bool _Bool
45
46 /* The other macros must be usable in preprocessor directives.  */
47 #define false 0
48 #define true 1
49 #define __bool_true_false_are_defined 1
50
51 #endif /* _STDBOOL_H */