From f36b435c9f24dce655b736096f2671471bbf14f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Fri, 15 Sep 2023 19:33:08 -0400 Subject: [PATCH] [msvc] Fix using the SDK with compliant mode enabled If using /Zc:__cplusplus and /Zc:preprocessor the workaround in place causes compile errors ; the "normal" version instead works. --- c74support/max-includes/ext_preprocessor.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/c74support/max-includes/ext_preprocessor.h b/c74support/max-includes/ext_preprocessor.h index 5c839b2..7035ee6 100644 --- a/c74support/max-includes/ext_preprocessor.h +++ b/c74support/max-includes/ext_preprocessor.h @@ -124,7 +124,13 @@ // C74_PASS_ARGS passes __VA_ARGS__ as multiple parameters to another macro, working around the following bug: // https://connect.microsoft.com/VisualStudio/feedback/details/521844/variadic-macro-treating-va-args-as-a-single-parameter-for-other-macros#details -#if _MSC_VER >= 1400 +#if _MSC_VER >= 1400 && _MSC_VER < 1937 && __cplusplus < 202003L +#define C74_MSVC_VAARGS_WORKAROUND 1 +#else +#define C74_MSVC_VAARGS_WORKAROUND 0 +#endif + +#if C74_MSVC_VAARGS_WORKAROUND # define C74_PASS_ARGS_LEFT ( # define C74_PASS_ARGS_RIGHT ) # define C74_PASS_ARGS(...) C74_PASS_ARGS_LEFT __VA_ARGS__ C74_PASS_ARGS_RIGHT @@ -179,7 +185,7 @@ // this is done to sign-extend and promote shorter integer types // - see object_method for an example -#if _MSC_VER >= 1400 +#if C74_MSVC_VAARGS_WORKAROUND #define C74_VARFUN(VARFUN_IMPL, ...) C74_JOIN_2(C74_VARFUN_, C74_NUM_ARGS(__VA_ARGS__)) C74_PASS_ARGS(VARFUN_IMPL, __VA_ARGS__) #else #define C74_VARFUN(VARFUN_IMPL, ...) C74_JOIN_2(C74_VARFUN_, C74_NUM_ARGS(__VA_ARGS__))( VARFUN_IMPL, __VA_ARGS__ )