1、可用如下
#ifndef _DEBUG_SET_
#define debug_print(format, ...) {fprintf(stderr, "[Libiot_ETH][%s, %s(), L:%d] > " format "\n", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__ );}
#endif
`
2、stderr的解释:
相对于stdout,当设定标准输出为到文件等情况时,stderr选项保证fprintf依旧串口输出到屏幕
3、关于
##__VA_ARGS__
#、##、__VA_ARGS__的使用 - auccy的博客 - CSDN博客 https://blog.csdn.net/auccy/article/details/88833659
宏的高级使用–##,VA_ARGS, FILE, __FUNCTION__等 - yiya1989的专栏 - CSDN博客 https://blog.csdn.net/yiya1989/article/details/7849588
`
``
`
4、注意空格问题
C++11 error: unable to find string literal operator 'operator" - nh5431313的专栏 - CSDN博客 https://blog.csdn.net/nh5431313/article/details/78753597
5、PS
Debug格式化输出----基于C语言 - micro虾米 - 博客园
https://www.cnblogs.com/microxiami/p/8027001.html
格式化输出syslog简易实现 - hancq - 博客园
https://www.cnblogs.com/hancq/p/5408317.html
Debug格式化输出----基于C语言 - micro虾米 - 博客园
https://www.cnblogs.com/microxiami/p/8027001.html