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
|
||||
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
|
||||
#
|
||||
|
@ -26,20 +26,25 @@
|
||||
#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)
|
||||
#ifdef WIN32
|
||||
#ifndef __cplusplus
|
||||
# if OMPI_NEED_C_BOOL
|
||||
# if OMPI_USE_STDBOOL_H
|
||||
/* If we're using <stdbool.h>, there is an implicit
|
||||
assumption that the C++ bool is the same size and has
|
||||
the same alignment. */
|
||||
# include <stdbool.h>
|
||||
# elif defined(WIN32)
|
||||
# define bool BOOL
|
||||
# define false FALSE
|
||||
# define true TRUE
|
||||
#elif OMPI_USE_STDBOOL_H
|
||||
/* If we're using <stdbool.h>, there is an implicit assumption that
|
||||
the C++ bool is the same size and has the same alignment. */
|
||||
#include <stdbool.h>
|
||||
# else
|
||||
/* We need to create a bool type and ensure that it's the same size /
|
||||
alignment as the C++ bool size / alignment */
|
||||
/* 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
|
||||
@ -48,11 +53,16 @@ typedef bool char
|
||||
typedef bool short
|
||||
# elif SIZEOF_BOOL == SIZEOF_INT && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_INT
|
||||
typedef bool int
|
||||
# elif SIZEOF_BOOL == SIZEOF_LONG && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_LONG
|
||||
typedef bool long
|
||||
# elif defined(SIZEOF_LONG_LONG) && defined(OMPI_ALIGNMENT_LONG) && SIZEOF_BOOL == SIZEOF_LONG && OMPI_ALIGNMENT_CXX_BOOL == OMPI_ALIGNMENT_LONG
|
||||
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
|
||||
|
||||
/*
|
||||
* Maximum size of a filename path.
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user