From 7359eea1846c53aded031e47c3cbfd752dd8104c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Jun 2012 07:08:16 +0200 Subject: [PATCH] use bool type where it's available when using gcc, compile as C99 --- src/CMakeLists.txt | 1 + src/platform.h | 19 +++---------------- src/util/bool.h | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 src/util/bool.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1cc33a9b9..9e9eb8d6c 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ project (eressea C) IF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL") ELSE(CMAKE_COMPILER_IS_GNUCC) MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}") ENDIF(CMAKE_COMPILER_IS_GNUCC) diff --git a/src/platform.h b/src/platform.h index d72545cc6..679737ec2 100644 --- a/src/platform.h +++ b/src/platform.h @@ -246,22 +246,9 @@ extern char *strdup(const char *s); # define unused(a) (a) #endif /* ghs || __GNUC__ || ..... */ -/**** **** - ** The Eressea boolean type ** - **** ****/ -#if defined(BOOLEAN) -# define boolean BOOLEAN -#else -typedef int boolean; /* not bool! wrong size. */ -#endif -#ifndef __cplusplus -# define false ((boolean)0) -# define true ((boolean)!false) -#endif -#ifdef __cplusplus -} -#endif - +#include "util/bool.h" +typedef bool boolean; + #ifndef INLINE_FUNCTION # define INLINE_FUNCTION #endif diff --git a/src/util/bool.h b/src/util/bool.h new file mode 100644 index 000000000..0bdebc9ec --- /dev/null +++ b/src/util/bool.h @@ -0,0 +1,15 @@ +#if HAVE_STDBOOL_H +# include +#else +# if ! HAVE__BOOL +# ifdef __cplusplus +typedef bool _Bool; +# else +typedef unsigned char _Bool; +# endif +# endif +# define bool _Bool +# define false 0 +# define true 1 +# define __bool_true_false_are_defined 1 +#endif