1 /* 2 * Portability wrapper around <stdbool.h>. 3 * 4 * Provides the bool and _Bool types and the true and false constants, 5 * following the C99 specification, on hosts that don't have stdbool.h. This 6 * logic is based heavily on the example in the Autoconf manual. 7 * 8 * The canonical version of this file is maintained in the rra-c-util package, 9 * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. 10 * 11 * Written by Russ Allbery <eagle@eyrie.org> 12 * 13 * The authors hereby relinquish any claim to any copyright that they may have 14 * in this work, whether granted under contract or by operation of law or 15 * international treaty, and hereby commit to the public, at large, that they 16 * shall not, at any time in the future, seek to enforce any copyright in this 17 * work against any person or entity, or prevent any person or entity from 18 * copying, publishing, distributing or creating derivative works of this 19 * work. 20 */ 21 22 #ifndef PORTABLE_STDBOOL_H 23 #define PORTABLE_STDBOOL_H 1 24 25 /* 26 * Allow inclusion of config.h to be skipped, since sometimes we have to use a 27 * stripped-down version of config.h with a different name. 28 */ 29 #ifndef CONFIG_H_INCLUDED 30 # include <config.h> 31 #endif 32 33 #if HAVE_STDBOOL_H 34 # include <stdbool.h> 35 #else 36 # if HAVE__BOOL 37 # define bool _Bool 38 # else 39 # ifdef __cplusplus 40 typedef bool _Bool; 41 # elif _WIN32 42 # include <windef.h> 43 # define bool BOOL 44 # else 45 typedef unsigned char _Bool; 46 # define bool _Bool 47 # endif 48 # endif 49 # define false 0 50 # define true 1 51 # define __bool_true_false_are_defined 1 52 #endif 53 54 /* 55 * If we define bool and don't tell Perl, it will try to define its own and 56 * fail. Only of interest for programs that also include Perl headers. 57 */ 58 #ifndef HAS_BOOL 59 # define HAS_BOOL 1 60 #endif 61 62 #endif /* !PORTABLE_STDBOOL_H */ 63