checkasm: Fix building with MSVC
The glue code in our headers, for integrating with the external checkasm, was incompatible with MSVC. MSVC has a nonstandard handling of __VA_ARGS__ with macros; when one macro invokes another macro, __VA_ARGS__ gets treated as one single parameter and can't map to more than one parameter in the invoked macro. (In other words, when calling another macro, __VA_ARGS__ must map in its entirety to a ... parameter of the other macro.) Modern versions of MSVC do implement the correct mode as well, but defaults to the old one for backwards compatibility. To choose the new mode, we'd have to build our code with -Zc:preprocessor. That's certainly doable, but it's fairly easy to avoid the issue as well. To avoid this issue, change the variadic PIXEL_RECT(...) to explicitly names its arguments. There's actually no variability in the arguments involved here. (Alternatively, we could force the preprocessor to expand the arguments one extra time, avoiding the issue, with e.g. "#define EXPAND(x) x" and wrapping PIXEL_RECT with it, e.g. "#define PIXEL_RECT(...) EXPAND(BUF_RECT(pixel, __VA_ARGS__))".) See [1], [2] and [3] for more discussion on the matter. [1] https://stackoverflow.com/a/5134656/3115956 [2] https://stackoverflow.com/a/7459803/3115956 [2] https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-160
Loading
Please register or sign in to comment