How to make a variadic macro (variable number of arguments)

前端 未结 5 1535
遥遥无期
遥遥无期 2020-11-22 11:48

I want to write a macro in C that accepts any number of parameters, not a specific number

example:

#define macro( X )  something_complicated( whateve         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 12:33

    I don't think that's possible, you could fake it with double parens ... just as long you don't need the arguments individually.

    #define macro(ARGS) some_complicated (whatever ARGS)
    // ...
    macro((a,b,c))
    macro((d,e))
    

提交回复
热议问题