George pointed out last night that I didn't take into account the fact
that the C compiler may support bool with no help from <stdbool.h>. So add another configure test and adjust ompi_config_bottom.h as appropriate. Since the #if logic in ompi_config_bottom.h got a little complicated w.r.t. bool, I indented to make the conditionals clear. This commit was SVN r3291.
Этот коммит содержится в:
родитель
4ee39ac7af
Коммит
eb4267d6d2
14
configure.ac
14
configure.ac
@ -179,6 +179,20 @@ if test $ac_cv_type_long_double = yes; then
|
|||||||
fi
|
fi
|
||||||
OMPI_C_GET_ALIGNMENT(void *, OMPI_ALIGNMENT_VOID_P)
|
OMPI_C_GET_ALIGNMENT(void *, OMPI_ALIGNMENT_VOID_P)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Does the C compiler native support "bool"? (i.e., without
|
||||||
|
# <stdbool.h> or any other help)
|
||||||
|
#
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for C bool type)
|
||||||
|
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
|
||||||
|
AC_INCLUDES_DEFAULT]],
|
||||||
|
[[bool bar, foo = true; bar = foo;]]),
|
||||||
|
[OMPI_NEED_C_BOOL=0 MSG=yes],[OMPI_NEED_C_BOOL=1 MSG=no])
|
||||||
|
AC_DEFINE_UNQUOTED(OMPI_NEED_C_BOOL, $OMPI_NEED_C_BOOL,
|
||||||
|
[Whether the C compiler supports "bool" without any other help (such as <stdbool.h>)])
|
||||||
|
AC_MSG_RESULT([$MSG])
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for other compiler characteristics
|
# Check for other compiler characteristics
|
||||||
#
|
#
|
||||||
|
@ -26,32 +26,42 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're in C, bring in the bool type and true/false constants.
|
* If we're in C, we may need to bring in the bool type and true/false
|
||||||
|
* constants. OMPI_NEED_C_BOOL will be true if the compiler either
|
||||||
|
* needs <stdbool.h> or doesn't define the bool type at all.
|
||||||
*/
|
*/
|
||||||
#if !defined(__cplusplus)
|
#ifndef __cplusplus
|
||||||
#ifdef WIN32
|
# if OMPI_NEED_C_BOOL
|
||||||
#define bool BOOL
|
# if OMPI_USE_STDBOOL_H
|
||||||
#define false FALSE
|
/* If we're using <stdbool.h>, there is an implicit
|
||||||
#define true TRUE
|
assumption that the C++ bool is the same size and has
|
||||||
#elif OMPI_USE_STDBOOL_H
|
the same alignment. */
|
||||||
/* If we're using <stdbool.h>, there is an implicit assumption that
|
# include <stdbool.h>
|
||||||
the C++ bool is the same size and has the same alignment. */
|
# elif defined(WIN32)
|
||||||
#include <stdbool.h>
|
# define bool BOOL
|
||||||
#else
|
# define false FALSE
|
||||||
/* We need to create a bool type and ensure that it's the same size /
|
# define true TRUE
|
||||||
alignment as the C++ bool size / alignment */
|
# else
|
||||||
#define false 0
|
/* We need to create a bool type and ensure that it's the
|
||||||
#define true 1
|
same size / alignment as the C++ bool size /
|
||||||
#if SIZEOF_BOOL == SIZEOF_CHAR && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_CHAR
|
alignment */
|
||||||
|
# define false 0
|
||||||
|
# define true 1
|
||||||
|
# if SIZEOF_BOOL == SIZEOF_CHAR && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_CHAR
|
||||||
typedef bool char
|
typedef bool char
|
||||||
#elif SIZEOF_BOOL == SIZEOF_SHORT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_SHORT
|
# elif SIZEOF_BOOL == SIZEOF_SHORT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_SHORT
|
||||||
typedef bool short
|
typedef bool short
|
||||||
#elif SIZEOF_BOOL == SIZEOF_INT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_INT
|
# elif SIZEOF_BOOL == SIZEOF_INT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_INT
|
||||||
typedef bool int
|
typedef bool int
|
||||||
#else
|
# elif SIZEOF_BOOL == SIZEOF_LONG && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_LONG
|
||||||
#error Cannot find a C type that corresponds to the size and alignment of C++ bool!
|
typedef bool long
|
||||||
#endif
|
# elif defined(SIZEOF_LONG_LONG) && defined(OMPI_ALIGNMENT_LONG) && SIZEOF_BOOL == SIZEOF_LONG && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_LONG
|
||||||
#endif
|
typedef bool long long
|
||||||
|
# else
|
||||||
|
# error Cannot find a C type that corresponds to the size and alignment of C++ bool!
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user