Hi everyone, the problem is what I have in this macro
int _x=0;\
for(int i=0;i<n_addrs;i++){\
if(memcmp(s1,&(s2->##type),6)!=0){\
_x=-1;\
}else{\
break;\
}\
}\
_x;\
})
s1 is a simple array, and s2 is a structure with 4 vectors as members like this
typedef struct example{
char[6] one,
char[6] two,
char[6] three
}example;
Now for my own reason, I need to create a function that compares the s1 array of 6 bytes with only a member of the example, so for this purpose I wrote ADD_CMP using the ## operator to be as general as possible. So, I defined:
#define one
#define two
#define three
and I used the function different times this way, hoping for macro success
ADD_COMP(some_array,example1,one)
ADD_COMP(some_array,example1,two)
ADD_COMP(some_array,example1,three)
but the compiler returns as an error:
error: pasting "->" and "one" does not give a valid preprocessing token
error: pasting "->" and "two" does not give a valid preprocessing token
error: pasting "->" and "three" does not give a valid preprocessing token
How can I fix this without writing the same function for each member of the structure?