几天前,在CSDN论坛看到这么一则讨论:在宏定义中怎么使用可变参数?(http://expert.csdn.net/Expert/topic/2925/2925165.xml)。楼主希望能定义这样的macro:
#define fun1(a, b, ...) fun2(__FILE__, __LINE__, a, b, ...)
我猜楼主是想写trace,如果不能使用可变参数的macro,那么就得像MFC那样写一堆TRACE macros:
// 取自 MFC 7.1 的 afx.h
// The following trace macros are provided for backward compatiblity
// (they also take a fixed number of parameters which provides
// some amount of extra error checking)
#define TRACE0(sz) TRACE(_T("%s"), _T(sz))
#define TRACE1(sz, p1) TRACE(_T(sz), p1)
#define TRACE2(sz, p1, p2) TRACE(_T(sz), p1, p2)
#define TRACE3(sz, p1, p2, p3) TRACE(_T(sz), p1, p2, p3)
太丑陋了!还好,C99