qt - mingw 发出无数关于忽略 "dll import"属性的警告

标签 qt warnings mingw dllimport

我正在使用 mingw32-make 来编译一个使用 opengl 的 qt 项目,它可以正确编译所有内容,但它会发出无数以下形式的警告消息:

c:/qt3/include/qcolor.h:67: warning: inline function `int qGray(int, int, 
int)' declared as dllimport: attribute ignored

对于这个特定的实例,函数声明是:

Q_EXPORT inline int qGray( int r, int g, int b )// convert R,G,B to gray 0..255
{ return (r*11+g*16+b*5)/32; }

我的问题是,为什么它会发出所有这些警告?我如何才能在不抑制其他合法警告(即与我的代码直接相关且可能是潜在问题的警告)的情况下抑制它们?

更重要的是,为什么 mingw 首先忽略 dll 导入属性?

最佳答案

我认为如果定义了以下宏之一,Qt 应该只将 Q_EXPORT(Qt 4 中的 Q_DECL_EXPORT)定义为 dllexport/import 属性,因此请确保您的 makefile 或代码包含 Qt header (最终将包含 qglobal .h) 没有定义它们中的任何一个:WIN32、_WIN32、__WIN32__、WIN64、_WIN64、__WIN64__。或者您可以在编译(或预处理器)标志中将 Q_EXPORT 定义为空,然后 Qt 应该跳过定义它。

关于qt - mingw 发出无数关于忽略 "dll import"属性的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/526958/

相关文章:

c++ - 一个相当大的 C++ 开源项目,易于使用 MinGW 实现和构建?

windows - MinGW GCC 通配符

python - 这个警告在哪里发出 'QApplication: invalid style override passed, ignoring it.' ?

c++ - QFileSystemWatcher:检测文件是否已刷新

php - socket_connect() : unable to connect [10061] - target machine actively refused it

javascript - 循环 file_put_contents 偶尔会触发 "failed to open stream"警告

python - Matplotlib:删除有关 matplotlib.use() 的警告

c++ - QT 5 - 无法连接到不同类别的 Slot

qt - 使用 qmake 链接 .proto 文件

c++ - 如何将c/c++编译为ms-dos .com程序?