https://stackoverflow.com/questions/15864461/suppress-wtautological-compare-warning
You can disable it for the entire file by adding -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(...)
macro instances.
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