以下代码生成警告:
warning C4244: 'initializing': conversion from 'int64_t' to 'int', possible loss of data
使用CL 19(带-W3 )。
#include <inttypes.h> #include <climits> int main() { int64_t a = INT_MAX; int b = a+1; }但是,只要我包含任何与Qt相关的内容,
#include <QApplication>警告消失了。 但我希望这些警告显示给我自己的文件。 这个Qt是否隐藏了自己的警告泄漏到我的来源? 我可以避免吗?
The code below generates a warning:
warning C4244: 'initializing': conversion from 'int64_t' to 'int', possible loss of data
using CL 19 (with -W3).
#include <inttypes.h> #include <climits> int main() { int64_t a = INT_MAX; int b = a+1; }However it seems as soon as I include anything Qt related like:
#include <QApplication>the warning goes away. But I want those warnings to show for my own files. Is this Qt hiding its own warnings leaking into my source ? And can I avoid it ?
最满意答案
qglobal.h禁用了一堆过于冗长的警告,它几乎包含在任何Qt头中(间接)。 相关代码在这里 。
要重新启用它们, 请将QT_CC_WARNINGS添加到您的定义中 (在qmake项目中, DEFINES += QT_CC_WARNINGS )。 我很确定这会触发Qt标头的警告......
A bunch of overly verbose warnings get disabled by qglobal.h, which is included (indirectly) by virtually any Qt header. Relevant code is here.
To reenable them, add QT_CC_WARNINGS to your defines (in a qmake project, DEFINES += QT_CC_WARNINGS). I'm pretty sure this will trigger warnings from Qt headers...
更多推荐
发布评论