diff --git a/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h b/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h index 3e074cd11..2c2ad7d94 100644 --- a/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h +++ b/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h @@ -5,6 +5,20 @@ */ /// @file IRmacros.h +/** + * VA_OPT_SUPPORTED macro to check if __VA_OPT__ is supported + * Source: https://stackoverflow.com/a/48045656 + */ +/// @cond TEST +#define PP_THIRD_ARG(a, b, c, ...) c +#define VA_OPT_SUPPORTED_I(...) \ + PP_THIRD_ARG(__VA_OPT__(, false), true, false, false) +#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?) +/// @endcond +/** + * VA_OPT_SUPPORTED end + */ + /** * COND() Set of macros to facilitate single-line conditional compilation * argument checking. @@ -13,8 +27,14 @@ * * Usage: * COND([||/&&...], , ) + * + * NB: If __VA_OPT__ macro not supported, the will be expanded! */ /// @cond TEST +#if !VA_OPT_SUPPORTED +// #pragma message("Compiler without __VA_OPT__ support") +#define COND(cond, a, b) a +#else #define NOTHING #define EXPAND(...) __VA_ARGS__ #define STUFF_P(a, ...) __VA_OPT__(a) @@ -24,6 +44,7 @@ #define NEGATE(a) VA_TEST(a, a) #define COND_P(cond, a, b) STUFF(a, cond)STUFF(b, NEGATE(cond)) #define COND(cond, a, b) EXPAND(COND_P(cond, a, b)) +#endif /// @endcond /** * end of COND() set of macros