Skip to content

Commit 12d8e7c

Browse files
committed
[cmake][msvc] Enable standards-conforming preprocessor
Since we now only support Visual Studio 2019 16.7 and newer, we're able to use the /Zc:preprocessor flag that turns on the standards-conforming preprocessor. Among other things, it correctly expands __VA_ARGS__. This enables removal of some boilerplate in D135128. Reviewed By: Bigcheese, thieta Differential Revision: https://reviews.llvm.org/D135128
1 parent 4b21ecf commit 12d8e7c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ if( MSVC )
481481

482482
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
483483

484+
# Enable standards-conforming preprocessor.
485+
# https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor
486+
append("/Zc:preprocessor" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
487+
484488
# Some projects use the __cplusplus preprocessor macro to check support for
485489
# a particular version of the C++ standard. When this option is not specified
486490
# explicitly, macro's value is "199711L" that implies C++98 Standard.

0 commit comments

Comments
 (0)