//从C99编译器之后,宏定义开始支持可变参数列表了...
//在头文件中放如下代码:
#define IS_DEBUG 0 //日志输出开关,当设置为0时,为关闭,不会占用微处理器的任何flash空间
#if(IS_DEBUG)
#define DEBUG(format, ...) printf("[debug]%s:%d %s()| "format"\r\n",__FILE__,__LINE__,__FUNCTION__,##__VA_ARGS__)
#else
#define DEBUG(format, ...)
#endif
//在头文件中放如下代码:
#define IS_DEBUG 0 //日志输出开关,当设置为0时,为关闭,不会占用微处理器的任何flash空间
#if(IS_DEBUG)
#define DEBUG(format, ...) printf("[debug]%s:%d %s()| "format"\r\n",__FILE__,__LINE__,__FUNCTION__,##__VA_ARGS__)
#else
#define DEBUG(format, ...)
#endif
//例子(目前在KEIL5和IAR中都已经测试通过):
DEBUG("sys is running");
DEBUG("sys good:%d,%s",1,"200");