我的代码中有一些类似以下的日志宏:
#define LOG_MSG (pri, msg, ... ) \
if (pri > PriorityLevel ) \
printf( msg, ##\__VA_ARGS__);
我知道可以使用LCOV_EXCL_START,LCOV_EXCL_STOP或LCOV_EXCL_LINE来禁止一个分支。但如果我想在宏中包含这个注释,那么它只有在每次调用LOG_MSG时才能起作用:
LOG_MSG(ERROR, "An Error has occurred\n");//LCOV_EXCL_LINE
但是,如果我把这个注释放在宏里面,LCOV就不能识别它。例如,下面的代码仍然会产生分支。
#define LOG_MSG (pri, msg, ... ) \
if (pri > PriorityLevel ) \
printf( msg, ##\__VA_ARGS__);//LCOV_EXCL_LINE
有没有一种好的方法在宏中自行压缩这些分支?