simplecpp
simplecpp copied to clipboard
Preprocessing failure with comma in macro
Input:
#define COUNTER_NAME(NAME, ...) NAME##Count
#define COMMA ,
#define DECLARE_COUNTERS(LIST) unsigned long LIST(COUNTER_NAME, COMMA);
#define ACTUAL_LIST(FUNCTION, SEPARATOR) \
FUNCTION(event1, int, foo) SEPARATOR \
FUNCTION(event2, char, bar)
DECLARE_COUNTERS(ACTUAL_LIST)
Output of gcc -E:
#1 "cppcheck-issue-xxxx.cpp"
#1 "<built-in>"
#1 "<command-line>"
#1 "cppcheck-issue-xxxx.cpp"
#10 "cppcheck-issue-xxxx.cpp"
unsigned long event1Count , event2Count;
simplecpp output:
test.c:4: syntax error: failed to expand 'DECLARE_COUNTERS', Wrong number of parameters for macro 'ACTUAL_LIST'.
Here is a simpler test case:
#define COMMA ,
#define MULTI(SEPARATOR) A SEPARATOR B
#define VARS MULTI(COMMA)
unsigned VARS;
gives a similar error:
issues/simpleComma.c:4: syntax error: failed to expand 'VARS', Wrong number of parameters for macro 'MULTI'.