simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

Failure to expand macro with arguments containing comma

Open chrchr-github opened this issue 1 year ago • 5 comments

https://sourceforge.net/p/cppcheck/discussion/development/thread/73af296865

#define ADDER_S(a,b) a+b
#define ADDER(x) ADDER_S(x)
#define ARGUMENTS 1, 2

#define RUN  ADDER(ARGUMENTS)

int test(void) {
    //ADDER(ARGUMENTS);                     // Works
    RUN;                                    // Fails!!
    return 0;
}

It looks like a token ,, is created somehow.

chrchr-github avatar Oct 02 '24 12:10 chrchr-github

It looks like a token ,, is created somehow.

That's INNER_COMMA, but it's only reset in one of the Macro::expand() overloads.

chrchr-github avatar Oct 02 '24 14:10 chrchr-github

INNER_COMMA got removed in https://github.com/danmar/simplecpp/commit/0442161, so it's worth to give it another try.

datadiode avatar Oct 04 '24 10:10 datadiode

I think I tested with head already.

chrchr-github avatar Oct 04 '24 17:10 chrchr-github

I think I tested with head already.

I'm sure I did.

datadiode avatar Oct 05 '24 10:10 datadiode

You're correct, it has been fixed. Should we add a test case?

chrchr-github avatar Oct 05 '24 10:10 chrchr-github