Unexpected predefined macro behaviour when pasting tokens

前端 未结 3 752
囚心锁ツ
囚心锁ツ 2021-01-24 08:52

The following (test with gcc -E blah.c):

#define UNUSED(type) type UNUSED_ ## __COUNTER__
UNUSED(char const *)
UNUSED(int)

Generat

3条回答
  •  野性不改
    2021-01-24 09:21

    I believe you must "double expand" it:

    #define STR(x)    #x
    #define UNUSED(type) type UNUSED_ ## STR(__COUNTER__)
    UNUSED(char const *) 
    UNUSED(int) 
    

提交回复
热议问题