microsoft / wil

Windows Implementation Library
MIT License
2.57k stars 234 forks source link

TraceLogging.h preprocessor conformance #448

Closed dunhor closed 2 months ago

dunhor commented 2 months ago

@duhowett hit an issue where the TraceLogging.h header gave issues when compiling with /Zc:preprocessor. Turns out all of the issues were related to using an empty __VA_ARGS__ after a comma, which passes a single empty argument. The fix is to use the ##__VA_ARGS__ compiler extension that all major compilers support now, which will remove the trailing comma if __VA_ARGS__ is empty.

NOTE: It would be more conformant to use __VA_OPT__ for this purpose, however we can't yet assume >= C++20 and forking all of these code paths would be excessive.

Additional note: Looks like we can finally enable -fno-ms-compatibility with Clang, which revealed a couple more issues that have been fixed.