diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2021-06-01 13:49:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 13:49:39 (GMT) |
commit | 50d0888f491821435f6884c0c4c516f69ff67927 (patch) | |
tree | cfb3c7737ad9850667771206bc6f457da4e489fb /config | |
parent | 4ef33ef7cd0f2af55b34682b6949a101a68436bb (diff) | |
download | hdf5-50d0888f491821435f6884c0c4c516f69ff67927.zip hdf5-50d0888f491821435f6884c0c4c516f69ff67927.tar.gz hdf5-50d0888f491821435f6884c0c4c516f69ff67927.tar.bz2 |
C++ warning and build fixes (#707)
* Committing clang-format changes
* C++ build and warning updates
* Fixes all warnings on C++ (with gcc 9.3)
* Updates CMake and Autotools C++ builds
* Undo warning clobber
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'config')
-rw-r--r-- | config/cmake/H5cxx_config.h.in | 16 | ||||
-rw-r--r-- | config/cmake/H5pubconf.h.in | 3 | ||||
-rw-r--r-- | config/cmake/HDFCXXCompilerFlags.cmake | 25 | ||||
-rw-r--r-- | config/cmake/HDFCompilerFlags.cmake | 22 | ||||
-rw-r--r-- | config/cmake/HDFFortranCompilerFlags.cmake | 14 | ||||
-rw-r--r-- | config/cmake_ext_mod/HDFCXXTests.cpp | 46 | ||||
-rw-r--r-- | config/cmake_ext_mod/HDFUseCXX.cmake | 99 | ||||
-rw-r--r-- | config/gnu-cxxflags | 1 | ||||
-rw-r--r-- | config/gnu-warnings/cxx-9 | 2 |
9 files changed, 30 insertions, 198 deletions
diff --git a/config/cmake/H5cxx_config.h.in b/config/cmake/H5cxx_config.h.in deleted file mode 100644 index b5ae8ce..0000000 --- a/config/cmake/H5cxx_config.h.in +++ /dev/null @@ -1,16 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* src/H5cxx_config.h.in Created manually. */ - -/* Define if offsetof extension is present */ -#cmakedefine H5_HAVE_OFFSETOF ${H5_HAVE_OFFSETOF} - diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 0176c7a..45ab8b8 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -26,9 +26,6 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Define if C++ compiler recognizes offsetof */ -#cmakedefine H5_CXX_HAVE_OFFSETOF @CXX_HAVE_OFFSETOF@ - /* Define the default plugins path to compile */ #cmakedefine H5_DEFAULT_PLUGINDIR "@H5_DEFAULT_PLUGINDIR@" diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index e2904ca..260bbe0 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -71,10 +71,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") @@ -121,9 +117,9 @@ if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") - # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # list (APPEND H5_CXXFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + # list (APPEND H5_CXXFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") @@ -147,7 +143,7 @@ if (NOT MSVC AND NOT MINGW) ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) @@ -157,14 +153,14 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.9") endif () - # Append more extra warning flags that only gcc 5.1+ know about + # Append more extra warning flags that only gcc 5.1+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") @@ -175,13 +171,13 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXxFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") @@ -193,7 +189,7 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") @@ -211,10 +207,11 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-9") endif () endif () else () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index bb6ad78..0775f59 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -81,10 +81,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- # Option to allow the user to interpret certain warnings as errors @@ -178,7 +174,7 @@ if (NOT MSVC AND NOT MINGW) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) @@ -188,12 +184,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -203,12 +199,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) @@ -218,7 +214,7 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -231,17 +227,17 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") endif () - # Append more extra warning flags that only gcc 9.3+ know about + # Append more extra warning flags that only gcc 9.3+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") endif () - # Append more extra warning flags that only gcc 10.x+ know about + # Append more extra warning flags that only gcc 10.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) if (HDF5_ENABLE_DEV_WARNINGS) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 8b631ad..18ab621 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -80,37 +80,37 @@ if (NOT MSVC AND NOT MINGW) if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") #endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") #endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") #endif () diff --git a/config/cmake_ext_mod/HDFCXXTests.cpp b/config/cmake_ext_mod/HDFCXXTests.cpp deleted file mode 100644 index 08ccb34..0000000 --- a/config/cmake_ext_mod/HDFCXXTests.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifdef CXX_HAVE_OFFSETOF - -#include <stdio.h> -#include <stddef.h> - -#ifdef FC_DUMMY_MAIN -#ifndef FC_DUMMY_MAIN_EQ_F77 -# ifdef __cplusplus -extern "C" -# endif -int FC_DUMMY_MAIN() -{ return 1;} -#endif -#endif -int -main () -{ - - 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) - - ; - return 0; -} - -#endif diff --git a/config/cmake_ext_mod/HDFUseCXX.cmake b/config/cmake_ext_mod/HDFUseCXX.cmake deleted file mode 100644 index 423f74a..0000000 --- a/config/cmake_ext_mod/HDFUseCXX.cmake +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# -# This file provides functions for C++ support. -# -#------------------------------------------------------------------------------- -ENABLE_LANGUAGE (CXX) -set (HDF_PREFIX "H5") - -#------------------------------------------------------------------------------- -# Fix CXX flags if we are compiling staticly on Windows using -# Windows_MT.cmake from config/cmake/UserMacros -#------------------------------------------------------------------------------- -if (BUILD_STATIC_CRT_LIBS) - TARGET_STATIC_CRT_FLAGS () -endif () - -#----------------------------------------------------------------------------- -# Configure Checks which require CXX compilation must go in here -# not in the main ConfigureChecks.cmake files, because if the user has -# no CXX compiler, problems arise. -#----------------------------------------------------------------------------- -include (CheckIncludeFileCXX) -include (TestForSTDNamespace) - -# For other CXX specific tests, use this MACRO. -macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) - if (NOT DEFINED ${OTHER_TEST}) - set (MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") - set (OTHER_TEST_ADD_LIBRARIES) - if (HDF5_REQUIRED_LIBRARIES) - set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") - endif () - - foreach (def - HAVE_SYS_TIME_H - HAVE_UNISTD_H - HAVE_SYS_TYPES_H - HAVE_SYS_SOCKET_H - HAVE_SYS_FILE_H - ) - if ("${${HDF_PREFIX}_${def}}") - set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") - endif () - endforeach () - - if (LARGEFILE) - set (MACRO_CHECK_FUNCTION_DEFINITIONS - "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" - ) - endif () - - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (TRACE "Performing ${OTHER_TEST}") - endif () - TRY_COMPILE (${OTHER_TEST} - ${CMAKE_BINARY_DIR} - ${HDF_RESOURCES_EXT_DIR}/HDFCXXTests.cpp - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${OTHER_TEST_ADD_LIBRARIES}" - OUTPUT_VARIABLE OUTPUT - ) - if (${OTHER_TEST} EQUAL 0) - set (${OTHER_TEST} 1 CACHE INTERNAL "CXX test ${FUNCTION}") - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Success") - endif () - else () - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Failed") - endif () - set (${OTHER_TEST} "" CACHE INTERNAL "CXX test ${FUNCTION}") - file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Performing CXX Test ${OTHER_TEST} failed with the following output:\n" - "${OUTPUT}\n" - ) - endif () - endif () -endmacro () - -#----------------------------------------------------------------------------- -# Check a bunch of cxx functions -#----------------------------------------------------------------------------- -if (CMAKE_CXX_COMPILER_LOADED) - foreach (cxx_test - CXX_HAVE_OFFSETOF - ) - HDF_CXX_FUNCTION_TEST (${cxx_test}) - endforeach () -endif () diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index 0a7c63e..4fe5782 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -260,6 +260,7 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc 9 if test $cxx_vers_major -ge 9; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-9)" fi ################# diff --git a/config/gnu-warnings/cxx-9 b/config/gnu-warnings/cxx-9 new file mode 100644 index 0000000..d897de2 --- /dev/null +++ b/config/gnu-warnings/cxx-9 @@ -0,0 +1,2 @@ +# Turn this on when the C++ wrappers obey the Rule of Five +-Wno-deprecated-copy |