Fix compilation ESP8266

https://github.com/crankyoldgit/IRremoteESP8266/pull/1881/files
This commit is contained in:
Stephan Hadinger 2022-09-17 14:35:34 +02:00
parent 914859ad48
commit 412d5d6938

View File

@ -5,6 +5,20 @@
*/ */
/// @file IRmacros.h /// @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 * COND() Set of macros to facilitate single-line conditional compilation
* argument checking. * argument checking.
@ -13,8 +27,14 @@
* *
* Usage: * Usage:
* COND(<define_to_test>[||/&&<more_define>...], <true_result>, <false_result>) * COND(<define_to_test>[||/&&<more_define>...], <true_result>, <false_result>)
*
* NB: If __VA_OPT__ macro not supported, the <true_result> will be expanded!
*/ */
/// @cond TEST /// @cond TEST
#if !VA_OPT_SUPPORTED
// #pragma message("Compiler without __VA_OPT__ support")
#define COND(cond, a, b) a
#else
#define NOTHING #define NOTHING
#define EXPAND(...) __VA_ARGS__ #define EXPAND(...) __VA_ARGS__
#define STUFF_P(a, ...) __VA_OPT__(a) #define STUFF_P(a, ...) __VA_OPT__(a)
@ -24,6 +44,7 @@
#define NEGATE(a) VA_TEST(a, a) #define NEGATE(a) VA_TEST(a, a)
#define COND_P(cond, a, b) STUFF(a, cond)STUFF(b, NEGATE(cond)) #define COND_P(cond, a, b) STUFF(a, cond)STUFF(b, NEGATE(cond))
#define COND(cond, a, b) EXPAND(COND_P(cond, a, b)) #define COND(cond, a, b) EXPAND(COND_P(cond, a, b))
#endif
/// @endcond /// @endcond
/** /**
* end of COND() set of macros * end of COND() set of macros