Extend the comment.
[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, we define true and false as
33    enum constants, not only as macros.
34    It is tempting to write
35       typedef enum { false = 0, true = 1 } _Bool;
36    so that gdb prints values of type 'bool' symbolically. But if we do
37    this, values of type '_Bool' may promote to 'int' or 'unsigned int'
38    (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
39    (see ISO C 99 6.3.1.1.(2)).  */
40 #ifndef __cplusplus
41 # if !@HAVE__BOOL@
42 enum { false = 0, true = 1 };
43 typedef signed char _Bool;
44 # endif
45 #else
46 typedef bool _Bool;
47 #endif
48 #define bool _Bool
49
50 /* The other macros must be usable in preprocessor directives.  */
51 #define false 0
52 #define true 1
53 #define __bool_true_false_are_defined 1
54
55 #endif /* _STDBOOL_H */