Using commas inside a macro without parenthesis: How can I mix and match with a template?

后端 未结 3 1348
终归单人心
终归单人心 2020-12-09 21:57

Consider a simple macro:

#define ECHO(x) x

ECHO(foo(1, 2))

This produces the exact output we expect:

foo(1, 2)
         


        
3条回答
  •  無奈伤痛
    2020-12-09 22:09

    A variadic macro may help:

    #define ECHO(x...) x
    
    ECHO(foo(1, 2))
    ECHO(template)
    

提交回复
热议问题