What does a double hash (##) in a macro mean?

后端 未结 2 1029
灰色年华
灰色年华 2021-01-17 11:45

In the below code, what does the ## do?

 #define MAKE_TYPE(myname) \\
 typedef int myname ## Id; \\
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 12:19

    icecrime is correct, but something important to point out in the definition is that the tokens need to be valid preprocessing tokens. Examples:

    #define CONCAT(a,b) a ## b
    CONCAT(ClassyClass, ); // bad,  is not a valid preprocessing token
    CONCAT(Symbol, __LINE__); // valid as both are valid tokens
    

提交回复
热议问题