I am currently attempting to define a function based on a compiler flag. If the TRACE flag is set, then I want to define a macro to pass information to a trace component.
#define TRACERPTR(Reporter * pReporter, traceComponent eComponent, traceLevel eLevel, string sFormat, formatArgs...) \
if (pReporter != NULL) { pReporter->trace(eComponent, eLevel, sFormat, ##formatArgs); }
Reporter is a class, defined in the same .h file, above this macro. I need to pass a pointer of a reporter object, which is then used to call the trace function.
However, I get a compiler error:
error: “*” may not appear in macro
parameter list
I was curious as to what would occur if I just removed the “*” — which results in the error “macro parameters must be comma-separated”.
Any idea as to what I am doing wrong here?
To my knowledge, in C, at least, macro parameters aren’t typed. It’s all symbol substitution. Just use
pReporterrather thanReporter * pReporterorReporter pReporter.(The same applies to the other parameters for your macro, I suppose.)