输出调试技巧 PRINTF()
#define PRINTF(...) \ do { \ printf( "%d:%s::",__LINE__, __FUNCTION__);\ printf(__VA_ARGS__);\ fflush(stdout); \ } while(0)
PRINTF("write license file success");
PRINTF("!Your license is expired,Please upgrade permissions");
输出效果如下:
111:writeLicFile::write license file success
168:validationThreadFunc::!Your license is expired,Please upgrade permissions
注:这样的输出,在大型项目中,可以知道是哪个函数多行号代码出错的。