Skip to content

Commit

Permalink
Add support for the new MSVC preprocessor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derobins committed Mar 7, 2024
1 parent fe5d0d5 commit d3457b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/H5win32defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d3457b8

Please sign in to comment.