I have an list of tokens defined as:
#define TOKENS ACC, STOP, RUN, BACK
This list might change. I would like to create an array of function pointers based on that list by doing something similar to:
int (*callbacks[])(const char * arg) =
{
some_macro_shenanigans(TOKENS)
};
And some_macro_shenanigans(TOKENS)
should expand to ACC_callback, STOP_callback, ...
and so on. Later I would like to create an array of strings based on TOKENS
like this:
const char * const token_str[] = some_other_macro_shenanigans(TOKENS);
Which would expand to something equivalent to this:
const char * const token_str[] = [ "ACC", "STOP", "RUN", "BACK" /* and others if present */ ];
Is it doable?