From 3f37d67b3ca8f6693400a2d266753aaae63ded93 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Wed, 20 Jul 2016 11:10:42 -0500 Subject: [svn-r30209] HDFFV-9467: Use the same test programs for CMake and autotools -- Modified C++ to use the same test programs. Tested: jelly (gnu) --- configure.ac | 8 ++++--- m4/aclocal_cxx.m4 | 68 ++++++++++++------------------------------------------- 2 files changed, 19 insertions(+), 57 deletions(-) diff --git a/configure.ac b/configure.ac index 5ba01c6..a6d1192 100644 --- a/configure.ac +++ b/configure.ac @@ -695,12 +695,14 @@ if test "X$HDF_CXX" = "Xyes"; then ## Checking if C++ can handle namespaces PAC_PROG_CXX_NAMESPACE - ## Checking if C++ has offsetof extension - PAC_PROG_CXX_OFFSETOF - ## if C++ can handle static cast PAC_PROG_CXX_STATIC_CAST + ## Checking if C++ has offsetof extension, + ## note: this test has to be the last of the C++ tests because it sets a definition + ## which would be used in the other tests, causing them to fail. + PAC_PROG_CXX_OFFSETOF + else AC_MSG_RESULT([no]) CXX="no" diff --git a/m4/aclocal_cxx.m4 b/m4/aclocal_cxx.m4 index b44ae82..9d47193 100644 --- a/m4/aclocal_cxx.m4 +++ b/m4/aclocal_cxx.m4 @@ -26,14 +26,11 @@ dnl we need as part of the C++ support. To distinquish these, they dnl have a [PAC] prefix. dnl Checking if C++ needs old style header files in includes - AC_DEFUN([PAC_PROG_CXX_HEADERS],[ AC_MSG_CHECKING([if $CXX needs old style header files in includes]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#include + TEST_SRC="`(echo \"#define OLD_HEADER_FILENAME 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { return 0; } - ])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([yes]) CXXFLAGS="${CXXFLAGS} -DOLD_HEADER_FILENAME" @@ -41,80 +38,43 @@ int main(void) { return 0; } ]) dnl Checking if ++ can handle namespaces - AC_DEFUN([PAC_PROG_CXX_NAMESPACE],[ AC_MSG_CHECKING([if $CXX can handle namespaces]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -namespace H5 { -int fnord; -} + TEST_SRC="`(echo \"#define HDF_NO_NAMESPACE 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { - using namespace H5; - fnord = 37; - return 0; -} - ])], [AC_MSG_RESULT([yes])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - CXXFLAGS="${CXXFLAGS} -DH5_NO_NAMESPACE" - AM_CXXFLAGS="${AM_CXXFLAGS} -DH5_NO_NAMESPACE"]) + CXXFLAGS="${CXXFLAGS} -DHDF_NO_NAMESPACE" + AM_CXXFLAGS="${AM_CXXFLAGS} -DHDF_NO_NAMESPACE"]) ]) dnl Checking if C++ supports std - AC_DEFUN([PAC_PROG_CXX_STD],[ AC_MSG_CHECKING([if $CXX supports std]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#include - -using namespace std; + TEST_SRC="`(echo \"#define HDF_NO_STD 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" -int main(void) { - string myString("testing namespace std"); - return 0; -} - ])], [AC_MSG_RESULT([yes])], + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) CXXFLAGS="${CXXFLAGS} -DH5_NO_STD" AM_CXXFLAGS="${AM_CXXFLAGS} -DH5_NO_STD"]) ]) dnl Checking if C++ has offsetof extension - AC_DEFUN([PAC_PROG_CXX_OFFSETOF],[ AC_MSG_CHECKING([if $CXX has offsetof extension]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([ - #include - #include - ],[ - struct index_st - { - unsigned char type; - unsigned char num; - unsigned int len; - }; - typedef struct index_st index_t; - int x,y; - x = offsetof(struct index_st, len); - y = offsetof(index_t, num) - ])],[AC_MSG_RESULT([yes]) + TEST_SRC="`(echo \"#define CXX_HAVE_OFFSETOF 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" + + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])],[AC_MSG_RESULT([yes]) AC_DEFINE([CXX_HAVE_OFFSETOF], [1], [Define if C++ compiler recognizes offsetof])], AC_MSG_RESULT([no])) ]) dnl Checking if C++ can handle static cast - AC_DEFUN([PAC_PROG_CXX_STATIC_CAST],[ AC_MSG_CHECKING([if $CXX can handle static cast]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -int main(void) { - float test_float; - int test_int; - test_float = 37.0; - test_int = static_cast (test_float); - return 0; -} - ])], [AC_MSG_RESULT([yes])], + TEST_SRC="`(echo \"#define NO_STATIC_CAST 1\"; cat $srcdir/config/cmake_ext_mod/HDFCXXTests.cpp)`" + + AC_LINK_IFELSE([AC_LANG_SOURCE([$TEST_SRC])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) CXXFLAGS="${CXXFLAGS} -DNO_STATIC_CAST" AM_CXXFLAGS="${AM_CXXFLAGS} -DNO_STATIC_CAST"]) -- cgit v0.12