- 论坛徽章:
- 59
|
本帖最后由 folklore 于 2012-05-23 21:06 编辑
回复 1# tujiaw
初来乍到, 请多多包涵,问题是这样的:
函数原来是这样的:
void Func(const char *file, int line, const char *format, ...);
现在我想包装一层让其自动传入参数__FILE__, __LINE__, 想象中是这样子的:
#define FUNC(const char *format, ...) \
Func(__FILE__, __LINE__, const char *format, ...)
这样以后直接用FUNC传入可变参数format就可以了, 不用每次都传入file和line.
但这样肯定是不行的,请问一下怎么实现我需要的功能?
gcc:[
- #define FUNC(file,line,format,...) void Func(file,line,format,##__VA_ARGS__);
- [[\code]
- vc&&gcc:
- [[code]
- #define FUNC(file,line,...) void Func(file, line, __VA_ARGS__);
- [
复制代码 good luck. |
|