I believe that the answer to my question is tied to C Preprocessor, Stringify the result of a macro. However, I'm having trouble applying the solution to my use case.
I have this function:
astNodePtr createNode(int lineno, int nodeType, ...);
I have this macro which goes along with it:
#define NODE(nodeType, ...) createNode(yylineno,nodeType,##__VA_ARGS__)
All works fine until I get to a line like this:
NODE(1,x,NODE(2,y,z))
My linker gives me an error: undefined reference to 'NODE'
EDIT:
I've tried (inspired by the fore-mentioned link)
#define EXPAND(x) ##x
#define NODE(nodeType, ...) createNode(yylineno,nodeType, EXPAND(__VA_ARGS__))
However, I got the same error.
EDIT:
I should mention that I also use the macro thus: NODE(5)
Therefore, I need the ##
in front of __VA_ARGS__
in order to avoid the trailing comma problem.