I have some problems with macro expansion in msvc compiler.
I expect the following code to be expanded to F x
, which it does on gcc and clang.
But msvc expands it to just F
ignoring x
token. What's going on here?
#define S(s) s
#define F()
#define M() S(S(F) x)
M() // expands to 'F' on msvc
However, without defining F()
it expands to F x
on msvc too, as expected.
#define S(s) s
// #define F()
#define M() S(S(F) x)
M() // expands to 'F x' on msvc
I'm using Compiler Explorer site to check this code. Compiler version is x64 msvc v19.latest.
CodePudding user response:
Use /Zc:preprocessor
to switch to the new, standard-conformant preprocessor. It behaves as you expect.