I am trying to use unique variable names every time my macro is expanded, I cannot come up with a solution
I have code something like this
#define _each(results,arr,i,v, f)\
for (i=0;i<len(arr);i++){\
v = arr[i];\
f\
}
I'd love to assign a unique variable name to I and V.
So when they are expanded i get
for(i1=0;i<len(arr);i++){ // first expansion
v = arr[i1];
// dostuff
}
for(i2=0;i<len(arr);i++){
v = arr[i2];
// do stuff
}
I've tried __Counter__
but i cant figure out how to reuse the variable
#define m(var1,var2) {\ // example calling use m(i,v)
var1 ##__COUNTER__ ;\ // prints i1
row = array[var1];\ // prints i, need i1
row = array[var1 ##__COUNTER__##]; // prints i2.. i need i1
If that makes sense..
I need to increment the variable names because i have one case where I nest the macro!