Preprocessing of this code with simplecpp:
#define CAT(a, b) CAT2(a, b)
#define CAT2(a, b) a ## b
#define FOO x
#define BAR() CAT(F, OO)
#define BAZ CAT(B, AR)()
BAZ
produces this result:
All mainstream preprocessors (GCC, Clang, MSVC) produce this result (https://godbolt.org/z/9GhhTarE3):
It seems that simplecpp decides to not expand CAT a second time during evaluation of BAZ. I don't know if this is correct from the point of view of the standard.
Some additional observations:
- If the last line is replaced with
CAT(B, AR)() then all preprocessors produce the same result: x.
- If
BAR() is converted from function-like macro to regular macro:
#define BAR CAT(F, OO)
#define BAZ CAT(B, AR)
then all preprocessors produce the same result: CAT ( F , OO ).
Preprocessing of this code with simplecpp:
produces this result:
All mainstream preprocessors (GCC, Clang, MSVC) produce this result (https://godbolt.org/z/9GhhTarE3):
It seems that simplecpp decides to not expand
CATa second time during evaluation ofBAZ. I don't know if this is correct from the point of view of the standard.Some additional observations:
CAT(B, AR)()then all preprocessors produce the same result:x.BAR()is converted from function-like macro to regular macro:CAT ( F , OO ).