Variadic macros with zero arguments

前端 未结 7 1238
失恋的感觉
失恋的感觉 2020-12-14 16:06

I am working on a call macro,

#define CALL(f,...) FN(f)->call((ref(new LinkedList()), __VA_ARGS__))

which when called,

C         


        
相关标签:
7条回答
  • 2020-12-14 16:56

    If you're using gcc/g++ there is a way:

    #define CALL(f,...) FN(f)->call((ref(new LinkedList()), ## __VA_ARGS__))
    

    From the fine manual:

    [...] if the variable arguments are omitted or empty, the `##' operator causes the preprocessor to remove the comma before it.

    So gcc has an extension/hack specifically for the problem you are facing.

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