From 1fb908c0dbf5bdde4d4aaaf78b48b6520d52de4c Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 1 Mar 2009 13:57:40 -0800 Subject: [PATCH] autoconf: detect the broken bool in OpenWatcom 1.8 OpenWatcom 1.8 has a C99 mode, which implements _Bool and . Unfortunately the implementation is broken, and doesn't let _Bool be implicitly converted to integer (as required by the C99 spec). Detect this case in autoconf. --- aclocal.m4 | 24 ++++++++++++++++++++++++ compiler.h | 2 +- configure.in | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/aclocal.m4 b/aclocal.m4 index e25d13d3..5159c11c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -13,3 +13,27 @@ AC_DEFUN(PA_ADD_CFLAGS, AC_MSG_RESULT([no]) CFLAGS="$pa_add_cflags__old_cflags")]) +dnl -------------------------------------------------------------------------- +dnl PA_WORKING_STDBOOL +dnl +dnl See if we have a working and bool support; in particular, +dnl OpenWatcom 1.8 has a broken _Bool type that we don't want to use. +dnl -------------------------------------------------------------------------- +AC_DEFUN(PA_WORKING_BOOL, +[AC_MSG_CHECKING([if $CC has a working bool type]) + AC_COMPILE_IFELSE( + [ +#ifndef __cplusplus +#include +#endif +int foo(bool x, int y) +{ + return x+y; +} + ], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_WORKING_BOOL, 1, + [Define to 1 if your compiler has a correct implementation of bool])], + [AC_MSG_RESULT([no])]) +]) + diff --git a/compiler.h b/compiler.h index 5e7e8c46..2c4cc9da 100644 --- a/compiler.h +++ b/compiler.h @@ -78,7 +78,7 @@ int vsnprintf(char *, size_t, const char *, va_list); #endif #ifndef __cplusplus /* C++ has false, true, bool as keywords */ -# ifdef HAVE_STDBOOL_H +# if defined(HAVE_STDBOOL_H) && defined(HAVE_WORKING_BOOL) # include # else /* This is sort of dangerous, since casts will behave different than diff --git a/configure.in b/configure.in index 0d536533..b47675be 100644 --- a/configure.in +++ b/configure.in @@ -97,6 +97,7 @@ AC_C_CONST AC_C_INLINE AC_C_RESTRICT AC_TYPE_SIZE_T +PA_WORKING_BOOL AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN)) AH_TEMPLATE(WORDS_BIGENDIAN, [Define to 1 if your processor stores words with the most significant -- 2.11.4.GIT