Skip to content

Commit 8fac2a5

Browse files
committed
Fix config for new MSVC preprocessor
1 parent 7e56a08 commit 8fac2a5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.github/workflows/gha.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ jobs:
195195
matrix:
196196
# MSVC2019 only supports /std:c++14, /std:c++17 and /std:c++latest
197197
cxx: [14, 17, 20]
198+
pp_flag: ["/Zc:preprocessor-", "/Zc:preprocessor"]
198199
steps:
199200
- uses: actions/checkout@v2
200201

@@ -225,7 +226,7 @@ jobs:
225226
-D CMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
226227
-D MSGPACK_BUILD_TESTS=ON `
227228
-D $CPPVER `
228-
-D CMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING /D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING /W3 /WX" `
229+
-D CMAKE_CXX_FLAGS="${{ matrix.pp_flag }} /D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING /D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING /W3 /WX" `
229230
-B build `
230231
-S .
231232
if ($LastExitCode -ne 0) { exit $LastExitCode }

include/msgpack/preprocessor/config/config.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@
2424
# define MSGPACK_PP_CONFIG_EDG() 0x0020
2525
# define MSGPACK_PP_CONFIG_DMC() 0x0040
2626
#
27+
# if !defined(__clang__) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL)
28+
# define MSGPACK_TRADITIONAL_MSVC 1
29+
# else
30+
# define MSGPACK_TRADITIONAL_MSVC 0
31+
# endif
32+
#
2733
# ifndef MSGPACK_PP_CONFIG_FLAGS
2834
# if defined(__GCCXML__) || defined(__WAVE__) || defined(__MWERKS__) && __MWERKS__ >= 0x3200
2935
# define MSGPACK_PP_CONFIG_FLAGS() (MSGPACK_PP_CONFIG_STRICT())
3036
# elif defined(__EDG__) || defined(__EDG_VERSION__)
31-
# if defined(_MSC_VER) && !defined(__clang__) && (defined(__INTELLISENSE__) || __EDG_VERSION__ >= 308)
37+
# if defined(_MSC_VER) && MSGPACK_TRADITIONAL_MSVC && (defined(__INTELLISENSE__) || __EDG_VERSION__ >= 308)
3238
# define MSGPACK_PP_CONFIG_FLAGS() (MSGPACK_PP_CONFIG_MSVC())
3339
# else
3440
# define MSGPACK_PP_CONFIG_FLAGS() (MSGPACK_PP_CONFIG_EDG() | MSGPACK_PP_CONFIG_STRICT())
3541
# endif
36-
# elif defined(_MSC_VER) && defined(__clang__)
42+
# elif defined(_MSC_VER) && !MSGPACK_TRADITIONAL_MSVC
3743
# define MSGPACK_PP_CONFIG_FLAGS() (MSGPACK_PP_CONFIG_STRICT())
3844
# elif defined(__MWERKS__)
3945
# define MSGPACK_PP_CONFIG_FLAGS() (MSGPACK_PP_CONFIG_MWCC())
@@ -75,7 +81,7 @@
7581
# define MSGPACK_PP_VARIADICS 0
7682
# elif defined(__CUDACC__)
7783
# define MSGPACK_PP_VARIADICS 1
78-
# elif defined(_MSC_VER) && defined(__clang__)
84+
# elif defined(_MSC_VER) && !MSGPACK_TRADITIONAL_MSVC
7985
# define MSGPACK_PP_VARIADICS 1
8086
# /* VC++ (C/C++) and Intel C++ Compiler >= 17.0 with MSVC */
8187
# elif defined _MSC_VER && _MSC_VER >= 1400 && (!defined __EDG__ || defined(__INTELLISENSE__) || defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1700)
@@ -94,7 +100,7 @@
94100
# elif !MSGPACK_PP_VARIADICS + 1 < 2
95101
# undef MSGPACK_PP_VARIADICS
96102
# define MSGPACK_PP_VARIADICS 1
97-
# if defined _MSC_VER && _MSC_VER >= 1400 && !defined(__clang__) && (defined(__INTELLISENSE__) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1700) || !(defined __EDG__ || defined __GCCXML__ || defined __CUDACC__ || defined __PATHSCALE__ || defined __DMC__ || defined __CODEGEARC__ || defined __BORLANDC__ || defined __MWERKS__ || defined __SUNPRO_CC || defined __HP_aCC || defined __MRC__ || defined __SC__ || defined __IBMCPP__ || defined __PGI))
103+
# if defined _MSC_VER && _MSC_VER >= 1400 && MSGPACK_TRADITIONAL_MSVC && (defined(__INTELLISENSE__) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1700) || !(defined __EDG__ || defined __GCCXML__ || defined __CUDACC__ || defined __PATHSCALE__ || defined __DMC__ || defined __CODEGEARC__ || defined __BORLANDC__ || defined __MWERKS__ || defined __SUNPRO_CC || defined __HP_aCC || defined __MRC__ || defined __SC__ || defined __IBMCPP__ || defined __PGI))
98104
# undef MSGPACK_PP_VARIADICS_MSVC
99105
# define MSGPACK_PP_VARIADICS_MSVC 1
100106
# endif

0 commit comments

Comments
 (0)