Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/IRmacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef IRMACROS_H_
#define IRMACROS_H_

/**
* COND() Set of macros to facilitate single-line conditional compilation
* argument checking.
* Found here: https://www.reddit.com/r/C_Programming/comments/ud3xrv/
* conditional_preprocessor_macro_anyone/
*
* Usage:
* COND(<define_to_test>[||/&&<more_define>...], <true_result>, <false_result)
*/
#define NOTHING
#define EXPAND(...) __VA_ARGS__
#define STUFF_P(a, ...) __VA_OPT__(a)
#define STUFF(...) STUFF_P(__VA_ARGS__)
#define VA_TEST_P(a,...) __VA_OPT__(NO)##THING
#define VA_TEST(...) VA_TEST_P(__VA_ARGS__)
#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))
/**
* end of COND() set of macros
*/

#endif // IRMACROS_H_
2 changes: 2 additions & 0 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include <string>
#endif // UNIT_TEST

#include "IRmacros.h"

// Library Version Information
// Major version number (X.x.x)
#define _IRREMOTEESP8266_VERSION_MAJOR 2
Expand Down
Loading