From d3457b8a2b0088e1ac25832de9014f247a98a370 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Mar 2024 18:11:18 -0800 Subject: [PATCH 1/3] Add support for the new MSVC preprocessor Microsoft has added a new, standards-conformant preprocessor to MSVC, which can be enabled with /Zc:preprocessor. This preprocessor trips over our HDopen() function-like variadic macro since it uses a hack that only works with the legacy MSVC preprocessor. This fix adds ifdefs to use the correct HDopen() macro depending on the MSVC preprocessor selected. --- src/H5win32defs.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index a9a462860aa..2c63e9350fc 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -50,12 +50,18 @@ struct timezone { #define HDlstat(S, B) _lstati64(S, B) #define HDmkdir(S, M) _mkdir(S) -/* Note that the variadic HDopen macro is using a VC++ extension - * where the comma is dropped if nothing is passed to the ellipsis. +/* 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. */ -#ifndef H5_HAVE_MINGW +#if defined(_MSC_VER) && !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL +/* Using the MSVC traditional preprocessor */ #define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__) #else +/* Using a standards conformant preprocessor */ #define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__) #endif From b340dc74377ce49a3471a59df078b050ad3876fe Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Mar 2024 18:22:11 -0800 Subject: [PATCH 2/3] Add release note for GH #2515 --- release_docs/RELEASE.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 8695b62bba4..c44b883556b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,6 +47,21 @@ New Features Configuration: ------------- + - Added support for the new MSVC preprocessor + + Microsoft added support for a new, standards-conformant preprocessor + to MSVC, which can be enabled with the /Zc:preprocessor option. This + preprocessor would trip over our HDopen() variadic function-like + macro, which uses a feature that only works with the legacy preprocessor. + + ifdefs have been added that select the correct HDopen() form and + allow building HDF5 with the /Zc:preprocessor option. + + The HDopen() macro is located in an internal header file and only + affects building the HDF5 library from source. + + Fixes GitHub #2515 + - Renamed HDF5_ENABLE_USING_MEMCHECKER to HDF5_USING_ANALYSIS_TOOL The HDF5_USING_ANALYSIS_TOOL is used to indicate to test macros that From 13d7d3931634c64f3dec49db86801ca62e05810d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Mar 2024 01:59:47 -0800 Subject: [PATCH 3/3] Add clarifying parens --- src/H5win32defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 2c63e9350fc..9630c5e2d42 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -57,7 +57,7 @@ struct timezone { * MinGW and the newer, conforming MSVC preprocessor do not exhibit this * behavior. */ -#if defined(_MSC_VER) && !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL +#if (defined(_MSC_VER) && !defined(_MSVC_TRADITIONAL)) || _MSVC_TRADITIONAL /* Using the MSVC traditional preprocessor */ #define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__) #else