C preprocessor tokenization does not expand macro?

后端 未结 2 1103

1) Why is the macro MSG not expanded in the following expression?

#define MSG Hello
#define HELLO(name)  MSG ## name

void HELLO(Dave) () {}
<
2条回答
  •  梦毁少年i
    2021-01-04 21:57

    #define MSG Hello
    #define cat(x, y) x ## y
    #define cat2(x, y) cat(x, y)
    #define HELLO(name) cat2(MSG,name)
    

    Live demo @ ideone.

提交回复
热议问题