I'm writing a complex macro and I need to pass also array initializer. Basically I have trouble to do:
#define INIT_ARR(VAR_NAME,ARR_DATA) int VAR_NAME[] = ARR_DATA
then I would call it
INIT_ARR(myNm,{1,2,3});
but preprocessors interprets any commas (also the one inside curly braces) as new macro parameter so it gives me error:
error: #55-D: too many arguments in invocation of macro "INIT_ARR"
preprocessor does not ignore () so I can do:
#define INIT_ARR(VAR_NAME,ARR_DATA) int VAR_NAME[] = {ARR_DATA}
INIT_ARR(myNm,(1,2,3));
but then it is interpreted as
int myNm[] = {(1,2,3)};
which is not correct for C.
Is there a way how to do it?? For example remove braces from parameter?
typedef(but as you hav to know how to initialise, this also is not very useful). Don't get too fancy with macros.ret = tested_funct(PARA,PARB,...); if(ret!=0) return PAR_X | ret; ret = chkModuleState({EXP_STATE}) return PAR_Y | ret;And this repeats 50 times... So I use macro for that. Calling macro repeatedly looks like a table and it is very nice to read what states are tested. True debugging is little obscured...