Skip to content

Commit e8139dc

Browse files
authored
Fix: Automagically select the right SHARED macro depending on the list of arguments. (#76)
1 parent c15f4d6 commit e8139dc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Arduino_Threads.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ public: \
8282
SinkNonBlocking<type> name{}; \
8383
private:
8484

85-
#define SHARED(name, type) \
85+
86+
#define SHARED_2_ARG(name, type) \
8687
Shared<type> name;
8788

88-
#define SHARED(name, type, size) \
89+
#define SHARED_3_ARG(name, type, size) \
8990
Shared<type, size> name;
9091

92+
#define GET_SHARED_MACRO(_1,_2,_3,NAME,...) NAME
93+
#define SHARED(...) GET_SHARED_MACRO(__VA_ARGS__, SHARED_3_ARG, SHARED_2_ARG)(__VA_ARGS__)
94+
95+
9196
#define ARDUINO_THREADS_CONCAT_(x,y) x##y
9297
#define ARDUINO_THREADS_CONCAT(x,y) ARDUINO_THREADS_CONCAT_(x,y)
9398

0 commit comments

Comments
 (0)