aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-06 23:10:50 -0700
committerChris Robinson <[email protected]>2014-05-06 23:10:50 -0700
commit38b98de78eceb77e0b2acc84877bf425ba0fb07d (patch)
tree0624c376a9705d16a0774254217fbae21c9df8cb
parent1aff37114a930a6a7fab7067572133345398b542 (diff)
Check for C99 _Bool support
-rw-r--r--CMakeLists.txt11
-rw-r--r--config.h.in6
-rw-r--r--include/bool.h18
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 */