From 10191b70de29680dfaa47e933fd268c12f9e5b33 Mon Sep 17 00:00:00 2001 From: skarg Date: Mon, 25 Aug 2008 15:34:16 +0000 Subject: [PATCH] Changed _Bool to be int8_t type rather than enum type. This should fix size compatibility with C++. --- bacnet-stack/ports/rtos32/stdbool.h | 2 +- bacnet-stack/ports/win32/stdbool.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bacnet-stack/ports/rtos32/stdbool.h b/bacnet-stack/ports/rtos32/stdbool.h index 2b7511a6..696ffd85 100644 --- a/bacnet-stack/ports/rtos32/stdbool.h +++ b/bacnet-stack/ports/rtos32/stdbool.h @@ -4,7 +4,7 @@ /* C99 Boolean types for compilers without C99 support */ #ifndef __cplusplus -typedef int _Bool; +typedef char _Bool; #ifndef bool #define bool _Bool #endif diff --git a/bacnet-stack/ports/win32/stdbool.h b/bacnet-stack/ports/win32/stdbool.h index 1ad2d54e..c55e9086 100644 --- a/bacnet-stack/ports/win32/stdbool.h +++ b/bacnet-stack/ports/win32/stdbool.h @@ -1,15 +1,23 @@ #ifndef _STDBOOL_H #define _STDBOOL_H +#include + /* C99 Boolean types for compilers without C99 support */ /* http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */ #if !defined(__cplusplus) #if !defined(__GNUC__) /* _Bool builtin type is included in GCC */ -typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; +/* ISO C Standard: 5.2.5 An object declared as + type _Bool is large enough to store + the values 0 and 1. */ +/* We choose 8 bit to match C++ */ +/* It must also promote to integer */ +typedef int8_t _Bool; #endif +/* ISO C Standard: 7.16 Boolean type */ #define bool _Bool #define true 1 #define false 0