So I've been using this code for generating such statements following This Reddit post:
#define LOOP(seq) END(A seq)
#define BODY(x) int x;
#define A(x) BODY(x) B
#define B(x) BODY(x) A
#define A_END
#define B_END
#define END(...) END_(__VA_ARGS__)
#define END_(...) __VA_ARGS__##_END
LOOP((a)(b)(c)) // int a; int b; int c;
However, as the author mentioned, this doesn't let you pass a state from outside the loop, in my case I need to pass a suffix from outside, so something like LOOP( = 5; , (a)(b)(c))) Would expand to int a = 5; int b = 5; int c = 5; for example.
Is there a boilerplate free solution for this? if not what would be the more elegant boilerplate-ful one that is only needed for this specific use case? Thanks!