I am trying to stringify the substitution (evaluation) of a macro concatenation. For example:
#include <stdio.h>
#define FOO_ONE 12
#define FOO_TWO 34
#define BAR_ONE 56
#define BAR_TWO 78
#define MAKE_MAC(mac) // ... what to do here?
void main(int argc, char *argv[])
{
printf("FOO: " MAKE_MAC(FOO) "\n");
printf("BAR: " MAKE_MAC(BAR) "\n");
}
The result I am seeking is:
FOO: 1234
BAR: 5678
I tried a few forms, I think the best attempt is this:
#define STRINGIFY(mac) #mac
#define CONCAT(mac1, mac2) STRINGIFY(mac1 ## mac2)
#define MAKE_MAC(mac) CONCAT(mac, _ONE) CONCAT(mac, _TWO)
But, it only gets me this far:
FOO: FOO_ONEFOO_TWO
BAR: BAR_ONEBAR_TWO
So, how can I add the extra step of evaluation of the resulting concatenated macro, before it gets stringified?