Suppress -Wtautological-compare warning

阅读 52

2023-09-06


https://stackoverflow.com/questions/15864461/suppress-wtautological-compare-warning

-Wno-tautological-compare to the Clang command line (after flags such as -Wall that turn warnings on). The disadvantage of this method is that the warning is now disabled everywhere in that translation unit, not just for the Q_ASSERT(...)

Another, more tedious but fine grained, method is to wrap every instance of the macro that generates this warning with the following:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-compare"

//出现警告的代码

#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-compare"

//出现警告的代码

#pragma clang diagnostic pop

精彩评论(0)

0 0 举报