定义以下打印宏的时候,C语言是可以编译通过的,
#define MyPrintf(str, args...) printf("[%s:%d]"str, __FUNCTION__, __LINE__, ##args)
而C++则会出现如下错误:
error: unable to find string literal operator‘operator""str’with‘const char [8]’,‘long unsigned int’arguments
解决方法是"[%s:%d]"和str之间加个空格,如下:
#define MyPrintf(str, args...) printf("[%s:%d]" str, __FUNCTION__, __LINE__, ##args)
error: unable to find string literal operator‘operator““str’with‘const char [8]’,‘long unsigned int’
最新推荐文章于 2023-10-12 22:45:00 发布