From 303c38cde9553307948e7eb47d8792d487de1d64 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 21 Oct 2004 19:57:00 +0000 Subject: [PATCH] Fix for bug 1030 -- ensure C and C++ bool's are the same size and alignment. Right now, we only check for char, short, and int. If we ever run across a platform where one of those three don't work, we'll need to extend ompi_config_bottom.h. :-) This commit was SVN r3271. --- include/ompi_config_bottom.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/ompi_config_bottom.h b/include/ompi_config_bottom.h index 16550d02a4..2fd5223ff6 100644 --- a/include/ompi_config_bottom.h +++ b/include/ompi_config_bottom.h @@ -15,9 +15,23 @@ */ #ifndef __cplusplus #if OMPI_USE_STDBOOL_H +/* If we're using , there is an implicit assumption that + the C++ bool is the same size and has the same alignment. */ #include #else -typedef enum { false, true } bool; +/* We need to create a bool type and ensure that it's the same size / + alignment as the C++ bool size / alignment */ +#define false 0 +#define true 1 +#if SIZEOF_BOOL == SIZEOF_CHAR && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_CHAR +typedef bool char +#elif SIZEOF_BOOL == SIZEOF_SHORT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_SHORT +typedef bool short +#elif SIZEOF_BOOL == SIZEOF_INT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_INT +typedef bool int +#else +#error Cannot find a C type that corresponds to the size and alignment of C++ bool! +#endif #endif #endif