Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* -*- buffer-read-only: t -*- vi: set ro: */ 00002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 00003 /* Copyright (C) 2001-2003, 2006-2011 Free Software Foundation, Inc. 00004 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3, or (at your option) 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software Foundation, 00018 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 00019 00020 #ifndef _GL_STDBOOL_H 00021 #define _GL_STDBOOL_H 00022 00023 /* ISO C 99 <stdbool.h> for platforms that lack it. */ 00024 00025 /* Usage suggestions: 00026 00027 Programs that use <stdbool.h> should be aware of some limitations 00028 and standards compliance issues. 00029 00030 Standards compliance: 00031 00032 - <stdbool.h> must be #included before 'bool', 'false', 'true' 00033 can be used. 00034 00035 - You cannot assume that sizeof (bool) == 1. 00036 00037 - Programs should not undefine the macros bool, true, and false, 00038 as C99 lists that as an "obsolescent feature". 00039 00040 Limitations of this substitute, when used in a C89 environment: 00041 00042 - <stdbool.h> must be #included before the '_Bool' type can be used. 00043 00044 - You cannot assume that _Bool is a typedef; it might be a macro. 00045 00046 - Bit-fields of type 'bool' are not supported. Portable code 00047 should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. 00048 00049 - In C99, casts and automatic conversions to '_Bool' or 'bool' are 00050 performed in such a way that every nonzero value gets converted 00051 to 'true', and zero gets converted to 'false'. This doesn't work 00052 with this substitute. With this substitute, only the values 0 and 1 00053 give the expected result when converted to _Bool' or 'bool'. 00054 00055 - C99 allows the use of (_Bool)0.0 in constant expressions, but 00056 this substitute cannot always provide this property. 00057 00058 Also, it is suggested that programs use 'bool' rather than '_Bool'; 00059 this isn't required, but 'bool' is more common. */ 00060 00061 00062 /* 7.16. Boolean type and values */ 00063 00064 /* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same 00065 definitions below, but temporarily we have to #undef them. */ 00066 #if defined __BEOS__ && !defined __HAIKU__ 00067 # include <OS.h> /* defines bool but not _Bool */ 00068 # undef false 00069 # undef true 00070 #endif 00071 00072 /* For the sake of symbolic names in gdb, we define true and false as 00073 enum constants, not only as macros. 00074 It is tempting to write 00075 typedef enum { false = 0, true = 1 } _Bool; 00076 so that gdb prints values of type 'bool' symbolically. But if we do 00077 this, values of type '_Bool' may promote to 'int' or 'unsigned int' 00078 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' 00079 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the 00080 enum; this ensures that '_Bool' promotes to 'int'. */ 00081 #if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__) 00082 /* A compiler known to have 'bool'. */ 00083 /* If the compiler already has both 'bool' and '_Bool', we can assume they 00084 are the same types. */ 00085 # if !@HAVE__BOOL@ 00086 typedef bool _Bool; 00087 # endif 00088 #else 00089 # if !defined __GNUC__ 00090 /* If @HAVE__BOOL@: 00091 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when 00092 the built-in _Bool type is used. See 00093 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html 00094 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html 00095 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html 00096 Similar bugs are likely with other compilers as well; this file 00097 wouldn't be used if <stdbool.h> was working. 00098 So we override the _Bool type. 00099 If !@HAVE__BOOL@: 00100 Need to define _Bool ourselves. As 'signed char' or as an enum type? 00101 Use of a typedef, with SunPRO C, leads to a stupid 00102 "warning: _Bool is a keyword in ISO C99". 00103 Use of an enum type, with IRIX cc, leads to a stupid 00104 "warning(1185): enumerated type mixed with another type". 00105 Even the existence of an enum type, without a typedef, 00106 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. 00107 The only benefit of the enum, debuggability, is not important 00108 with these compilers. So use 'signed char' and no enum. */ 00109 # define _Bool signed char 00110 # else 00111 /* With this compiler, trust the _Bool type if the compiler has it. */ 00112 # if !@HAVE__BOOL@ 00113 typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; 00114 # endif 00115 # endif 00116 #endif 00117 #define bool _Bool 00118 00119 /* The other macros must be usable in preprocessor directives. */ 00120 #define false 0 00121 #define true 1 00122 #define __bool_true_false_are_defined 1 00123 00124 #endif /* _GL_STDBOOL_H */