From 8f6bae04cea932ea44f94b3173355e12a93d1a68 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 18 Oct 2024 09:54:01 -0700 Subject: [PATCH 1/4] Set the C standard to 11 Ignores some of the older Autotools platform files, since the Autotools will be dropped in the next major release (and we don't have compilers on which to test, anyway). --- config/clang-flags | 8 +------- config/cmake/HDFCompilerFlags.cmake | 4 ++-- config/gnu-flags | 11 ++++------- config/nvidia-flags | 4 ++-- config/oneapi-flags | 4 ++-- release_docs/RELEASE.txt | 5 +++++ 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/config/clang-flags b/config/clang-flags index 844d6afa14e..585cb290035 100644 --- a/config/clang-flags +++ b/config/clang-flags @@ -116,14 +116,8 @@ if test "X-clang" = "X-$cc_vendor" -o "X-Apple LLVM" = "X-$cc_vendor"; then esac case "$host_os-$host_cpu" in - # cygwin needs the "-std=c99" flag removed, so make - # a specific case for Cygwin without the flag and a default - # case to add the flag everywhere else - cygwin-*) - ;; - *) - H5_CFLAGS="$H5_CFLAGS -std=c99" + H5_CFLAGS="$H5_CFLAGS -std=c11" ;; esac diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index e3364826ba6..2953d0e08ec 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -9,10 +9,10 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # -set (CMAKE_C_STANDARD 99) +set (CMAKE_C_STANDARD 11) set (CMAKE_C_STANDARD_REQUIRED TRUE) -set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") +set (CMAKE_C_FLAGS "${CMAKE_C11_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") message (VERBOSE "Warnings Configuration: C default: ${CMAKE_C_FLAGS}") #----------------------------------------------------------------------------- diff --git a/config/gnu-flags b/config/gnu-flags index 546f601e3c0..5bf8b7a8d22 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -117,18 +117,15 @@ if test "X-gcc" = "X-$cc_vendor"; then esac case "$host_os-$host_cpu" in - # Cygwin needs the "-std=c99" flag removed. - cygwin-*) - ;; - # On Solaris, gcc needs the gnu99 standard to pick up certain POSIX + # On Solaris, gcc needs the gnu11 standard to pick up certain POSIX # things. Do NOT use this as the gcc norm as this encourages the use # of non-standard gcc extensions. *solaris*) - H5_CFLAGS="$H5_CFLAGS -std=gnu99" + H5_CFLAGS="$H5_CFLAGS -std=gnu11" ;; - # Everybody else gets c99 as the standard. + # Everybody else gets C11 as the standard. *) - H5_CFLAGS="$H5_CFLAGS -std=c99" + H5_CFLAGS="$H5_CFLAGS -std=c11" ;; esac diff --git a/config/nvidia-flags b/config/nvidia-flags index 39bca831314..31b2aa0bd56 100644 --- a/config/nvidia-flags +++ b/config/nvidia-flags @@ -68,8 +68,8 @@ if test "X-nvc" = "X-$cc_vendor" -o "X-nvcc" = "X-$cc_vendor"; then # General # ########### - # Default to C99 standard. - H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=warn" + # Default to C11 standard. + H5_CFLAGS="$H5_CFLAGS $arch -std=c11 -Minform=warn" ############## # Production # diff --git a/config/oneapi-flags b/config/oneapi-flags index 629e93f02f1..32a7e7c61a7 100644 --- a/config/oneapi-flags +++ b/config/oneapi-flags @@ -80,8 +80,8 @@ if test "X-icx" = "X-$cc_vendor"; then # General # ########### - # Default to C99 standard. - H5_CFLAGS="$H5_CFLAGS $arch -std=c99" + # Default to C11 standard. + H5_CFLAGS="$H5_CFLAGS $arch -std=c11" ############## # Production # diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index cf9b65cc086..67e4816b49f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,6 +47,11 @@ New Features Configuration: ------------- + - The standard for building the library is now C11 + + We have updated the build files to set the C standard to C11, though + some platforms use gnu11 to get some GNU things to work. + - Added configuration option for internal threading/concurrency support: CMake: HDF5_ENABLE_THREADS (ON/OFF) (Default: ON) From 73db75055e11afce9cfb826b366062b990d05883 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 18 Oct 2024 10:07:30 -0700 Subject: [PATCH 2/4] Use the conforming preprocessor by default --- src/H5win32defs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 72d0e556157..383d9035d4b 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -48,9 +48,10 @@ struct timezone { * is dropped if nothing is passed to the ellipsis. * * MinGW and the newer, conforming MSVC preprocessor do not exhibit this - * behavior. + * behavior. The conforming preprocessor is also used by default with + * C11. */ -#if (defined(_MSC_VER) && !defined(_MSVC_TRADITIONAL)) || defined(_MSVC_TRADITIONAL) +#if defined(_MSVC_TRADITIONAL) /* Using the MSVC traditional preprocessor */ #define HDopen(S, F, ...) Wopen(S, F, __VA_ARGS__) #else From ea57b25b1f628577e5adcb282605d922404e8c66 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 18 Oct 2024 10:21:03 -0700 Subject: [PATCH 3/4] Completely remove the hacky preprocessor --- src/H5win32defs.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 383d9035d4b..677baee3e61 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -43,21 +43,8 @@ struct timezone { #define HDlstat(S, B) _lstati64(S, B) #define HDmkdir(S, M) _mkdir(S) -/* Note that with the traditional MSVC preprocessor, the variadic - * HDopen macro uses an MSVC-specific extension where the comma - * is dropped if nothing is passed to the ellipsis. - * - * MinGW and the newer, conforming MSVC preprocessor do not exhibit this - * behavior. The conforming preprocessor is also used by default with - * C11. - */ -#if defined(_MSVC_TRADITIONAL) -/* Using the MSVC traditional preprocessor */ -#define HDopen(S, F, ...) Wopen(S, F, __VA_ARGS__) -#else -/* Using a standards conformant preprocessor */ +/* We only support the standards conformant preprocessor */ #define HDopen(S, F, ...) Wopen(S, F, ##__VA_ARGS__) -#endif #define HDremove(S) Wremove(S) #define HDsetenv(N, V, O) Wsetenv(N, V, O) From da72f687264b621cb4e15892a139f07dd61203d9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 18 Oct 2024 10:52:51 -0700 Subject: [PATCH 4/4] Add a release note for the preprocessor changes --- release_docs/RELEASE.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 67e4816b49f..a20c02742d1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,6 +47,16 @@ New Features Configuration: ------------- + - Dropped support for the traditional MSVC preprocessor + + Visual Studio has recently started using a standards-compliant + preprocessor (In VS2019+) and this is the default in C11. + + https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170 + + Because of this, we've dropped support for the traditional + MSVC preprocessor. + - The standard for building the library is now C11 We have updated the build files to set the C standard to C11, though