M
Michael Blackney
I've been looking into cascaded macros and I can't seem to find if
what I'm doing is portable. I want to do something like:
#define THREE_ONES 1,1,1
#define ONE_TWO_THREE 1,2,3
#define JOIN_LISTS(a,b) JOIN_LISTS_PROCESSED(a,b)
#define JOIN_LISTS_PROCESSED(a1,b1,c1,a2,b2,c2) a1+a2,b1+b2,c1+c2
so that the statement:
{ JOIN_LISTS(THREE_ONES,ONE_TWO_THREE) },
will expand (one the first preprocessor pass) to:
{ JOIN_LISTS_PROCESSED(1,1,1,1,2,3) },
then expand on the second pass to:
{ 1+1, 1+2, 1+3 },
On my compiler (DJGPP) it works just fine - but is it portable? Do
all preprocessors use a similar replacement order?
what I'm doing is portable. I want to do something like:
#define THREE_ONES 1,1,1
#define ONE_TWO_THREE 1,2,3
#define JOIN_LISTS(a,b) JOIN_LISTS_PROCESSED(a,b)
#define JOIN_LISTS_PROCESSED(a1,b1,c1,a2,b2,c2) a1+a2,b1+b2,c1+c2
so that the statement:
{ JOIN_LISTS(THREE_ONES,ONE_TWO_THREE) },
will expand (one the first preprocessor pass) to:
{ JOIN_LISTS_PROCESSED(1,1,1,1,2,3) },
then expand on the second pass to:
{ 1+1, 1+2, 1+3 },
On my compiler (DJGPP) it works just fine - but is it portable? Do
all preprocessors use a similar replacement order?