microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.91k stars 1.64k forks source link

Use the new MSVC preprocessor #1734

Open abrauninger opened 1 year ago

abrauninger commented 1 year ago

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.

tiagomacarios commented 1 year ago

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

barcharcraz commented 1 year ago

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.