diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 893ef7e1e..0f5c87159 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -47,6 +47,9 @@ uqm_requirements() define_have_symbol getopt_long define_have_header regex.h + # Add define for HAVE__BOOL + define_have_type _Bool + # Add an environment variable for MACRO_WIN32 and MACRO___MINGW32__ define_have_macro WIN32 define_have_macro __MINGW32__ diff --git a/sc2/src/config_unix.h.in b/sc2/src/config_unix.h.in index 7c7158939..c8f0480f6 100644 --- a/sc2/src/config_unix.h.in +++ b/sc2/src/config_unix.h.in @@ -52,6 +52,8 @@ /* Defined if your system has wint_t of its own */ @HAVE_WINT_T@ +/* Defined if your system has _Bool of its own */ +@HAVE__BOOL@ + #endif /* _CONFIG_UNIX_H */ - diff --git a/sc2/src/config_win.h.in b/sc2/src/config_win.h.in index 032c253ed..31d154a9b 100644 --- a/sc2/src/config_win.h.in +++ b/sc2/src/config_win.h.in @@ -53,6 +53,9 @@ /* Defined if your system has wint_t of its own */ @HAVE_WINT_T@ +/* Defined if your system has _Bool of its own */ +@HAVE__BOOL@ + #endif /* _CONFIG_WIN_H */ diff --git a/sc2/src/sc2code/libs/uio/types.h b/sc2/src/sc2code/libs/uio/types.h index a30cad9e2..b92f7a4ad 100644 --- a/sc2/src/sc2code/libs/uio/types.h +++ b/sc2/src/sc2code/libs/uio/types.h @@ -21,11 +21,33 @@ #ifndef _uio_TYPES_H #define _uio_TYPES_H -typedef enum -{ - false = 0, - true -} uio_bool; +#include "config.h" + +// ISO C99 compatible boolean types. The ISO C99 standard defines: +// - An object declared as type _Bool, large enough to store the values 0 +// and 1, the rank of which is less than the rank of all other standard +// integer types. +// - A macro "bool", which expands to "_Bool". +// - A macro "true", which expands to the integer constant 1, suitable for +// use in #if preprocessing directives. +// - A macro "false", which expands to the integer constant 0, suitable for +// use in #if preprocessing directives. +// - A macro "__bool_true_false_are_defined", which expands to the integer +// constant 1, suitable for use in #if preprocessing directives. +#ifndef __bool_true_false_are_defined +#undef bool +#undef false +#undef true +#ifndef HAVE__BOOL +typedef unsigned char _Bool; +#endif /* HAVE_BOOL */ +#define bool _Bool +#define true 1 +#define false 0 +#define __bool_true_false_are_defined +#endif /* __bool_true_false_are_defined */ + +typedef bool uio_bool; typedef unsigned char uio_uint8; typedef signed char uio_sint8;