summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2024-03-07 16:52:32 (GMT)
committerGitHub <noreply@github.com>2024-03-07 16:52:32 (GMT)
commit30c34f927de96baf518e13a068b4564ec443bedf (patch)
tree74547ac30efd42991033fb57f7bf0a6c44315899 /src
parent2a2c683dc3f2d1accedc3dc4d8596d7988154acd (diff)
downloadhdf5-30c34f927de96baf518e13a068b4564ec443bedf.zip
hdf5-30c34f927de96baf518e13a068b4564ec443bedf.tar.gz
hdf5-30c34f927de96baf518e13a068b4564ec443bedf.tar.bz2
Add support for the new MSVC preprocessor (#4078)
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. Fixes #2515
Diffstat (limited to 'src')
-rw-r--r--src/H5win32defs.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index a9a4628..9630c5e 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