How can I use commercial at sign in Objective-C macro?

后端 未结 1 758
再見小時候
再見小時候 2020-12-03 18:55

How can I use commercial at sign in Objective-C macro?

I know it is not recommended, but seems it is possible somehow? Since libextobjc provides @

相关标签:
1条回答
  • 2020-12-03 19:33

    libextobjc uses preprocessor trickery to make you think it's an @command.

    #define weakify(...) \
        try {} @finally {} \
        metamacro_foreach_cxt(ext_weakify_,, __weak, __VA_ARGS__)
    

    Note the missing @ on the try. So @weakify expands into @try {} @finally {} [injected code].

    You could use the same trick, but I suggest you stick with plain macros.

    0 讨论(0)
提交回复
热议问题