From a4e833c50c002239af8c16667b1b072e6c6fa27f Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 07:37:08 -0700 Subject: 1.12: Brings 1.12 compiler options in line with develop (#1611) * Brings 1.12 compiler options in line with develop * Revert 'since' doxygen field in H5public.h --- config/BlankForm | 4 +- config/clang-warnings/developer-general | 1 - config/clang-warnings/general | 16 ++--- config/cmake/libh5cc.in | 2 +- config/cmake_ext_mod/ConfigureChecks.cmake | 111 ++++++++++++++--------------- config/gnu-warnings/cxx-general | 1 - config/gnu-warnings/developer-general | 3 - config/gnu-warnings/error-5 | 1 + config/gnu-warnings/error-general | 1 + config/gnu-warnings/general | 14 ++-- src/H5private.h | 4 +- src/H5public.h | 14 ++-- 12 files changed, 78 insertions(+), 94 deletions(-) diff --git a/config/BlankForm b/config/BlankForm index ce4bf53..14131b2 100644 --- a/config/BlankForm +++ b/config/BlankForm @@ -61,7 +61,7 @@ fi # # PROD_CFLAGS Flags to pass to the compiler to create a # PROD_CPPFLAGS production version of the library. These -# usualy exclude symbolic debugging switches +# usually exclude symbolic debugging switches # (like `-g') and include optimization switches # (like `-O'). # @@ -84,7 +84,7 @@ fi # compiler or a descendent of gcc such as EGCS or PGCC. # # AM_CFLAGS Flags added directly into this variable will -# be propogated to the compiler wrapper scripts (h5cc, +# be propagated to the compiler wrapper scripts (h5cc, # h5c++, et cetera) in addition to being used to compile # the library. # diff --git a/config/clang-warnings/developer-general b/config/clang-warnings/developer-general index 74d8404..b80552f 100644 --- a/config/clang-warnings/developer-general +++ b/config/clang-warnings/developer-general @@ -1,4 +1,3 @@ --Wformat-nonliteral -Wmissing-noreturn -Wsometimes-uninitialized -Wswitch-enum diff --git a/config/clang-warnings/general b/config/clang-warnings/general index f0c9b93..433dff9 100644 --- a/config/clang-warnings/general +++ b/config/clang-warnings/general @@ -8,19 +8,13 @@ -Wformat=2 -Wframe-larger-than=16384 -Wimplicit-fallthrough -# -# NOTE: Due to the divergence in the C and C++, we're dropping support for -# compiling the C library with a C++ compiler and dropping the -Wc++-compat -# warning. -# --Wno-c++-compat -# -# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add -# it to the developer flags. -# --Wno-format-nonliteral -Wnull-dereference -Wunused-const-variable -Wwrite-strings -Wpedantic -Wvolatile-register-var +# NOTE: Due to the divergence in the C and C++, we're dropping support for +# compiling the C library with a C++ compiler and dropping the -Wc++-compat +# warning. +# +-Wno-c++-compat diff --git a/config/cmake/libh5cc.in b/config/cmake/libh5cc.in index 6d54088..f5d8d4c 100644 --- a/config/cmake/libh5cc.in +++ b/config/cmake/libh5cc.in @@ -29,7 +29,7 @@ printf 'dir is %s\n' "$dir" # Show the configuration summary of the library recorded in the -# libhdf5.settings file residing in the lib directory. +# libhdf5.settings file reside in the lib directory. showconfigure() { cat $dir/lib/libhdf5.settings diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 56957f9..7b2c4eb 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -254,61 +254,61 @@ set (HDF_EXTRA_C_FLAGS) set (HDF_EXTRA_FLAGS) if (MINGW OR NOT WINDOWS) if (CMAKE_SYSTEM_NAME MATCHES "Linux") - # Linux Specific flags - # This was originally defined as _POSIX_SOURCE which was updated to - # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX - # functionality so clock_gettime and CLOCK_MONOTONIC are defined - # correctly. This was later updated to 200112L so that - # posix_memalign() is visible for the direct VFD code on Linux - # systems. - # POSIX feature information can be found in the gcc manual at: - # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html - set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L) - - # Need to add this so that O_DIRECT is visible for the direct - # VFD on Linux systems. - set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE) - - option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) - if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN) - set (msg "Performing TEST_LFS_WORKS") - try_run (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE - ${CMAKE_BINARY_DIR} - ${HDF_RESOURCES_EXT_DIR}/HDFTests.c - COMPILE_DEFINITIONS "-DTEST_LFS_WORKS" - ) - - # The LARGEFILE definitions were from the transition period - # and are probably no longer needed. The FILE_OFFSET_BITS - # check should be generalized for all POSIX systems as it - # is in the Autotools. - if (TEST_LFS_WORKS_COMPILE) - if (TEST_LFS_WORKS_RUN MATCHES 0) - set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) - set (LARGEFILE 1) - set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... yes") - endif () - else () - set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... no") - endif () - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n" - ) - endif () - else () - set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... no") - endif () - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Test TEST_LFS_WORKS Compile failed\n" - ) - endif () - endif () + # Linux Specific flags + # This was originally defined as _POSIX_SOURCE which was updated to + # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX + # functionality so clock_gettime and CLOCK_MONOTONIC are defined + # correctly. This was later updated to 200112L so that + # posix_memalign() is visible for the direct VFD code on Linux + # systems. + # POSIX feature information can be found in the gcc manual at: + # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html + set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L) + + # Need to add this so that O_DIRECT is visible for the direct + # VFD on Linux systems. + set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE) + + option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) + if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN) + set (msg "Performing TEST_LFS_WORKS") + try_run (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + COMPILE_DEFINITIONS "-DTEST_LFS_WORKS" + ) + + # The LARGEFILE definitions were from the transition period + # and are probably no longer needed. The FILE_OFFSET_BITS + # check should be generalized for all POSIX systems as it + # is in the Autotools. + if (TEST_LFS_WORKS_COMPILE) + if (TEST_LFS_WORKS_RUN MATCHES 0) + set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) + set (LARGEFILE 1) + set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... yes") + endif () + else () + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n" + ) + endif () + else () + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Compile failed\n" + ) + endif () + endif () set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS}) endif () endif () @@ -557,7 +557,6 @@ if (MINGW OR NOT WINDOWS) foreach (other_test HAVE_ATTRIBUTE HAVE_C99_FUNC -# STDC_HEADERS HAVE_FUNCTION HAVE_C99_DESIGNATED_INITIALIZER SYSTEM_SCOPE_THREADS diff --git a/config/gnu-warnings/cxx-general b/config/gnu-warnings/cxx-general index 9548cc0..1626524 100644 --- a/config/gnu-warnings/cxx-general +++ b/config/gnu-warnings/cxx-general @@ -17,7 +17,6 @@ -Winit-self -Winvalid-pch -Wmissing-include-dirs --Wno-format-nonliteral -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual diff --git a/config/gnu-warnings/developer-general b/config/gnu-warnings/developer-general index b34c4b7..460b874 100644 --- a/config/gnu-warnings/developer-general +++ b/config/gnu-warnings/developer-general @@ -1,9 +1,6 @@ # (suggestions from gcc, not code problems) -# NOTE: -Wformat-nonliteral added back in here (from being disabled in -# H5_CFLAGS) -Waggregate-return -Wdisabled-optimization --Wformat-nonliteral -Winline -Wmissing-format-attribute -Wmissing-noreturn diff --git a/config/gnu-warnings/error-5 b/config/gnu-warnings/error-5 index f7e1138..282ee3f 100644 --- a/config/gnu-warnings/error-5 +++ b/config/gnu-warnings/error-5 @@ -1,4 +1,5 @@ -Werror=incompatible-pointer-types +-Werror=int-conversion # # In GCC 4.4.7, the compiler gripes about shadowed global # declarations when a local variable uses the name of a diff --git a/config/gnu-warnings/error-general b/config/gnu-warnings/error-general index 8405c40..a66d284 100644 --- a/config/gnu-warnings/error-general +++ b/config/gnu-warnings/error-general @@ -11,6 +11,7 @@ -Werror=packed -Werror=pointer-sign -Werror=pointer-to-int-cast +-Werror=int-to-pointer-cast -Werror=redundant-decls -Werror=strict-prototypes -Werror=switch diff --git a/config/gnu-warnings/general b/config/gnu-warnings/general index a7a20b7..df4c613 100644 --- a/config/gnu-warnings/general +++ b/config/gnu-warnings/general @@ -15,18 +15,12 @@ -Winit-self -Winvalid-pch -Wmissing-include-dirs -# +-Wshadow +-Wundef +-Wwrite-strings +-pedantic # NOTE: Due to the divergence in the C and C++, we're dropping support for # compiling the C library with a C++ compiler and dropping the -Wc++-compat # warning. # -Wno-c++-compat -# -# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add -# it to the developer flags. -# --Wno-format-nonliteral --Wshadow --Wundef --Wwrite-strings --pedantic diff --git a/src/H5private.h b/src/H5private.h index b560d62..1ea172a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -166,8 +166,8 @@ #include #endif -/* Define the default VFD for this platform. - * Since the removal of the Windows VFD, this is sec2 for all platforms. +/* Define the default VFD for this platform. Since the removal of the + * Windows VFD, this is sec2 for all platforms. */ #define H5_DEFAULT_VFD H5FD_SEC2 diff --git a/src/H5public.h b/src/H5public.h index 87a282c..f7b27fc 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,13 +71,6 @@ #endif #endif -/* Include the Windows API adapter header early */ -#include "H5api_adpt.h" - -#ifdef __cplusplus -extern "C" { -#endif - /* Macros for enabling/disabling particular GCC warnings */ /* (see the following web-sites for more info: * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html @@ -485,6 +478,13 @@ typedef struct H5_alloc_stats_t { size_t peak_alloc_blocks_count; /**< Peak # of blocks allocated */ } H5_alloc_stats_t; +/* API adapter header (defines H5_DLL, etc.) */ +#include "H5api_adpt.h" + +#ifdef __cplusplus +extern "C" { +#endif + /* Functions in H5.c */ /** * \ingroup H5 -- cgit v0.12