I have an x-macro like this
#define LIST_OF_REGISTERS_R16 \
X(0x00, B) \
X(0x10, D) \
X(0x20, H) \
X(0x30, S)
and I define it like so
#define X(id, name) name--;
LIST_OF_REGISTERS_R16
#undef X
the problem is that in certain cases when I'm defining the macro, I need to sometimes select or deselect certain parts of this list, like I might need only B, D, H
(without the S) or I might need B,D,S
(without the H). I could define an x-macro for every possible combination but then I'd have 24 X-macros just for certain scenarios which is ugly and wasteful. Any help?
You could use use an
if
statement.however, if you're picking single registers out of the list, you're imho better of defining seperate macros for those.