diff options
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | config.h.in | 6 | ||||
-rw-r--r-- | include/bool.h | 18 |
3 files changed, 35 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2500960c..e6e0761e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,16 @@ CHECK_C_SOURCE_COMPILES( }" HAVE_C99_VLA) +# Check if we have C99 bool +CHECK_C_SOURCE_COMPILES( +"int main(int argc, char *argv[]) + { + volatile _Bool ret; + ret = (argc > 1) ? 1 : 0; + return ret ? -1 : 0; + }" +HAVE_C99_BOOL) + # Check if we have C11 static_assert CHECK_C_SOURCE_COMPILES( "int main() @@ -297,6 +307,7 @@ ENDIF() CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2))); int main() {return 0;}" HAVE_GCC_FORMAT) +CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H) IF(NOT HAVE_C99_VLA) CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H) diff --git a/config.h.in b/config.h.in index e8b944f6..090c00ae 100644 --- a/config.h.in +++ b/config.h.in @@ -92,6 +92,9 @@ /* Define if we have C99 variable-length array support */ #cmakedefine HAVE_C99_VLA +/* Define if we have C99 _Bool support */ +#cmakedefine HAVE_C99_BOOL + /* Define if we have C11 _Static_assert support */ #cmakedefine HAVE_C11_STATIC_ASSERT @@ -107,6 +110,9 @@ /* Define if we have stdint.h */ #cmakedefine HAVE_STDINT_H +/* Define if we have stdbool.h */ +#cmakedefine HAVE_STDBOOL_H + /* Define if we have stdalign.h */ #cmakedefine HAVE_STDALIGN_H diff --git a/include/bool.h b/include/bool.h new file mode 100644 index 00000000..6f714d09 --- /dev/null +++ b/include/bool.h @@ -0,0 +1,18 @@ +#ifndef AL_BOOL_H +#define AL_BOOL_H + +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#endif + +#ifndef bool +#ifdef HAVE_C99_BOOL +#define bool _Bool +#else +#define bool int +#endif +#define false 0 +#define true 1 +#endif + +#endif /* AL_BOOL_H */ |