8

While compiling a collection of files in a Qt project, I'm seeing lots of warnings similar to this one.

In file included from /usr/local/Trolltech/Qt-4.8.6/include/QtGui/qevent.h:52:
/usr/local/Trolltech/Qt-4.8.6/include/QtGui/qmime.h:119:10: warning: private field 'type' is not used [-Wunused-private-field]
    char type;
     ^

Per suggestions from various searches, I did add the entry

QMAKE_CXXFLAGS += -Wno-unused-private-field

to the .pro file and confirmed that it shows up properly in compiler invocations but I'm still getting that warning.

I'm running Qt on a Mac with clang.

Thanks in advance for any insights.

4

4 回答 4

10

根据这个答案,试试

QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field

似乎这些QMAKE_CXXFLAGS_WARN_ON标志是在 之后添加到编译器命令行的QMAKE_CXXFLAGS,并且会重新启用该警告(因为QMAKE_CXXFLAGScontains -Wall)。

于 2013-07-30T00:09:18.100 回答
2

由于 Qt 库而无法编译,这听起来很奇怪。由于我不在 Mac 上开发,我要检查的是支持的 Mac 版本/编译器以及如何在 Mac 上编译。之后,如果您符合要求,我会将其报告为错误。

另一种方法(正如此 QT-Bug 中已经报告的:To #include generate warnings)是在警告标头周围包含编译指示。

 #pragma GCC diagnostic ignored "-Wunused-private-field"
 #include <QtGui>
 #pragma GCC diagnostic warning "-Wunused-private-field"
于 2013-07-30T08:23:44.540 回答
1

首先,我不确定它是否存在 QT 错误,但我在 QT 论坛上发现了一个最近的问题。我希望它得到解决。

可能的错误:qmime.h 警告“char type is used”</a>

还有一个, Clang 4.2 警告 QMacMime 未使用的私有字段“类型”

这可能会对您有所帮助。

于 2013-07-30T08:50:12.447 回答
0

我不是一个铿锵的家伙,但根据http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers您可以将-isystem标志与那些 Qt 标头所在的目录一起使用in,这会将它们视为系统包含并抑制对它们的警告。

于 2013-07-25T00:24:27.320 回答