stdbool.h (4632B)
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 #if !defined _GL_STDBOOL_H 3 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) 4 #include <stdbool.h> 5 #else 6 /* Copyright (C) 2001-2003, 2006-2022 Free Software Foundation, Inc. 7 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU Lesser General Public License as published by 11 the Free Software Foundation; either version 2, or (at your option) 12 any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public License 20 along with this program; if not, see <https://www.gnu.org/licenses/>. */ 21 22 #ifndef _UNISTRING_STDBOOL_H 23 #define _UNISTRING_STDBOOL_H 24 25 /* ISO C 99 <stdbool.h> for platforms that lack it. */ 26 27 /* Usage suggestions: 28 29 Programs that use <stdbool.h> should be aware of some limitations 30 and standards compliance issues. 31 32 Standards compliance: 33 34 - <stdbool.h> must be #included before 'bool', 'false', 'true' 35 can be used. 36 37 - You cannot assume that sizeof (bool) == 1. 38 39 - Programs should not undefine the macros bool, true, and false, 40 as C99 lists that as an "obsolescent feature". 41 42 Limitations of this substitute, when used in a C89 environment: 43 44 - <stdbool.h> must be #included before the '_Bool' type can be used. 45 46 - You cannot assume that _Bool is a typedef; it might be a macro. 47 48 - Bit-fields of type 'bool' are not supported. Portable code 49 should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. 50 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'. 56 57 - C99 allows the use of (_Bool)0.0 in constant expressions, but 58 this substitute cannot always provide this property. 59 60 Also, it is suggested that programs use 'bool' rather than '_Bool'; 61 this isn't required, but 'bool' is more common. */ 62 63 64 /* 7.16. Boolean type and values */ 65 66 #ifdef __cplusplus 67 /* Assume the compiler has 'bool' and '_Bool'. */ 68 #else 69 /* <stdbool.h> is known to exist and work with the following compilers: 70 - GNU C 3.0 or newer, on any platform, 71 - Intel C, 72 - MSVC 12 (Visual Studio 2013) or newer, 73 - Sun C, on Solaris, if _STDC_C99 is defined, 74 - AIX xlc, if _ANSI_C_SOURCE is defined, 75 - HP C, on HP-UX 11.31 or newer. 76 It is know not to work with: 77 - Sun C, on Solaris, if __C99FEATURES__ is defined but _STDC_C99 is not, 78 - MIPSpro C 7.30, on IRIX. */ 79 # if (__GNUC__ >= 3) \ 80 || defined __INTEL_COMPILER \ 81 || (_MSC_VER >= 1800) \ 82 || (defined __SUNPRO_C && defined _STDC_C99) \ 83 || (defined _AIX && !defined __GNUC__ && defined _ANSI_C_SOURCE) \ 84 || defined __HP_cc 85 /* Assume the compiler has <stdbool.h>. */ 86 # include <stdbool.h> 87 # else 88 /* Need to define _Bool ourselves. As 'signed char' or as an enum type? 89 Use of a typedef, with SunPRO C, leads to a stupid 90 "warning: _Bool is a keyword in ISO C99". 91 Use of an enum type, with IRIX cc, leads to a stupid 92 "warning(1185): enumerated type mixed with another type". 93 Even the existence of an enum type, without a typedef, 94 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. 95 The only benefit of the enum, debuggability, is not important 96 with these compilers. So use 'signed char' and no enum. */ 97 # define _Bool signed char 98 # define bool _Bool 99 # endif 100 #endif 101 102 /* The other macros must be usable in preprocessor directives. */ 103 #ifdef __cplusplus 104 # if !defined _MSC_VER 105 # define false false 106 # define true true 107 # endif 108 /* In Sun C++ 5.11 (Solaris Studio 12.2) and older, 'true' as a preprocessor 109 expression evaluates to 0, not 1. Fix this by overriding 'true'. Note that 110 the replacement has to be of type 'bool'. */ 111 # if defined __SUNPRO_CC && true != 1 112 # undef true 113 # define true (!false) 114 # endif 115 #else 116 # undef false 117 # define false 0 118 # undef true 119 # define true 1 120 #endif 121 122 #define __bool_true_false_are_defined 1 123 124 #endif /* _UNISTRING_STDBOOL_H */ 125 #endif 126 #endif