Skip to content

Preprocessing failure with comma in macro #40

@danmar

Description

@danmar

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'.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions