the problem about different treatment to __VA_ARGS__ when using VS 2008 and GCC

后端 未结 2 1925
长情又很酷
长情又很酷 2021-01-18 05:13

I am trying to identify a problem because of an unusual usage of variadic macros. Here is the hypothetic macro:

#define va(c, d, ...) c(d, __VA_ARGS__)
#defi         


        
2条回答
  •  不思量自难忘°
    2021-01-18 05:47

    There is an easy way to deal with this problem:

    #define exp(...) __VA_ARGS__
    #define va(c, d, ...) c(d, __VA_ARGS__)
    #define var(a, b, ...)  exp(va(__VA_ARGS__, a, b))
    
    var(2, 3, printf, “%d %d %d\n”, 1);
    

    This will do the trick on VS 2008 and it won't affect gcc

提交回复
热议问题