如何处理vc中宏定义不能支持...表不定参数呢?
#define DPRINTF(...) printf(fmt, ...)比如以上实例,我想使用...作为不定参数,但是VC好像不能支持的??
程序代码:#include <stdarg.h> //包含va_list
#include <stdio.h> //包含vsprintf()
#include <string.h>
#define MyPrtLog CPrtLogFunc(__FILE__,__LINE__).out
class CPrtLogFunc
{
public:
char * m_file;
int m_line;
CPrtLogFunc(char * file,int line)
{
m_file=file;
m_line=line;
}
void out(char * format,...)
{
printf("In file %s line %d",m_file,m_line);
va_list arg_ptr;
va_start(arg_ptr, format);
vprintf(format,arg_ptr);
va_end(arg_ptr);
}
};
void main()
{
MyPrtLog("Error %s\n","错误");
}我在网上看到了C++ 实现方式,不知道纯C模式下怎么实现呢?