使用Qt缺少转换警告(Missing conversion warning using Qt)

编程入门 行业动态 更新时间:2024-10-25 09:24:54
使用Qt缺少转换警告(Missing conversion warning using Qt)

以下代码生成警告:

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...

更多推荐

本文发布于:2023-07-27 17:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1293562.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Missing   Qt   warning   conversion

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!