C: Expand Macro With Token Pasting

后端 未结 1 1144
心在旅途
心在旅途 2020-11-29 11:19

So here are some macros I have created:

#define MODULE_NAME moduleName
#define MODULE_STRUCT MODULE_NAME ## _struct
#define MODULE_FUNCTION(name) MODULE_NAME         


        
相关标签:
1条回答
  • 2020-11-29 11:41

    In C the operands of the token pasting operator ## are not expanded.

    You need a second level of indirection to get the expansion.

    #define CAT(x, y) CAT_(x, y)
    #define CAT_(x, y) x ## y
    
    0 讨论(0)
提交回复
热议问题