Skip to content

Commit fd265bd

Browse files
committed
[CMAKE] Enable proper definition of __cplusplus macro on MSVC
MSVC defaults to always reporting 199711L to satisfy broken C++ code. You have to add a command line argument to make it work correctly. See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
1 parent 5797340 commit fd265bd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sdk/cmake/msvc.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ endif()
3232

3333
add_definitions(/D__STDC__=1)
3434

35+
# Enable correct values of __cplusplus macro for newer standards
36+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)
37+
3538
# Ignore any "standard" include paths, and do not use any default CRT library.
3639
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
3740
add_compile_options(/X /Zl)

0 commit comments

Comments
 (0)