From 944d29e8bcb0350427a86dd3c8c97d370354f049 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 10 Jan 2021 20:03:28 +0100 Subject: [PATCH] Workaround CLANG preprocessor failure on Windows platform --- m-core.h | 6 ++++++ tests/test-mcore.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/m-core.h b/m-core.h index 1ae2ccc3..84b89c6a 100644 --- a/m-core.h +++ b/m-core.h @@ -1032,7 +1032,13 @@ M_BEGIN_PROTECTED_CODE /* Return 1 if there is a comma inside the argument list, 0 otherwise. */ +#if defined(__clang__) && defined(_MSC_VER) +// CLANG on windows has a non compliant preprocessor. Workaround it (with issue) +#define M_COMMA_P(...) M_RET_ARG76(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, useless) +#define M_COMMA_P_WORKAROUND 1 +#else #define M_COMMA_P(...) M_RETI_ARG76(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, useless) +#endif /* Return the string representation of the evaluated x. NOTE: Need to be used with M_APPLY to defer the evaluation */ diff --git a/tests/test-mcore.c b/tests/test-mcore.c index b1afc274..0b17e82e 100644 --- a/tests/test-mcore.c +++ b/tests/test-mcore.c @@ -158,9 +158,12 @@ static void test_empty(void) #define F3() #define F4() 1,2 assert (M_EMPTY_P(F0) == false); +#ifndef M_COMMA_P_WORKAROUND + // Disable tests on platform with a non working preprocessor assert (M_EMPTY_P(F1) == false); assert (M_EMPTY_P(F2) == false); assert (M_EMPTY_P(F3) == false); +#endif assert (M_EMPTY_P(F4) == false); #define G0 int #define G1 (void)