0

我面临 OCLint 和(例如)catch2宏扩展的问题:

未使用的局部变量 [unused|P3] 未使用局部变量“scopedMessage0”。
未使用的局部变量 [unused|P3] 未使用局部变量“scopedMessage1”。
...

每次我打电话时INFO("my message")(与 相同CHECK(my_condition))。

这不是我的代码,但在宏扩展后似乎在我的文件中,我想摆脱这些警告。
我看到的替代方案是:

// redefining the macro with a new name (but this changes the catch2 syntax, and make me modify lots of code) 
#define INFO_(msg) INFO(msg) //!OCLINT`
// redefining the macro with the same name INFO, but it does not compile
// suppressing the warning on each line (not very practical either)
INFO("my message") //!OCLINT
// redefining the catch2 macro in catch.hpp directly (but what if I update my version...)
// suppressing all OCLint warnings about unused variables (not acceptable)

OCLint 显然有一个关于禁用宏扩展的开放错误,但也许有一种解决方法或一种聪明的方法来处理一般情况下的这种情况(比如 grepping 结果以排除 scopeMessage?)。

谢谢您的帮助。

4

0 回答 0