cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Use the new MSVC preprocessor

Open abrauninger opened this issue 3 years ago • 2 comments

MSVC has a new preprocessor (https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/). To compile code with MSVC and C++20 we need to use the new preprocessor (/Zc:preprocessor).

This change updates cpprestsdk to use /Zc:preprocessor on versions of MSVC that support it (>= 16.6, which is _MSC_VER 1926).

Without code changes, /Zc:preprocessor causes build breaks due to empty __VA_ARGS__ in the macros defined in CheckMacros.h and TestMacros.h. Those headers already have versions of the macros that use the conformant ##__VA_ARGS__ syntax for non-MSVC compilers, so this change uses those existing macros for MSVC as well, on versions of MSVC that support /Zc:preprocessor.

abrauninger avatar Nov 30 '22 20:11 abrauninger

Perhaps the we should enabling the new code based on _MSVC_TRADITIONAL?

tiagomacarios avatar Nov 30 '22 20:11 tiagomacarios

Is this really necessary? this appears to only effect internal test headers, not public API headers, So I don't think this should fix any bugs related to using cpprest and the new preprocessor at the same time.

barcharcraz avatar Dec 06 '22 19:12 barcharcraz