Consider the following code
#define COMB(F, ...) F(__VA_ARGS__)
#define ADD(X, Y) (X + Y)
int foo() {
return COMB(ADD, 1, 2);
}
I have done some experiments on Godbolt. Microsoft VS v19.22 (with /E flag) fails at preprocessing the macro's. It gives the following error
int foo() {
return (1, 2 + );
}
example.cpp
<source>(8): warning C4003: not enough arguments for function-like macro invocation 'ADD'
GCC (with -E flag) simply outputs as expected
int foo() {
return (1 + 2);
}
I took a look at the C99 standard. But I am still not sure which compiler is doing it right?
I hope somebody can help me with clarifying this.