c++ - qdir.h 与 x.h (X11) : how to resolve? 冲突

标签 c++ qt x11

我正在尝试在使用 QDir 的项目中使用 QFileDialog。简单地包含该文件会导致编译错误(Qt 版本为 4.8.5):

In file included from file.qt.cpp:25:
In file included from another_file.qt.h:26:
In file included from /usr/include/QtCore/QDir:1:
/usr/include/QtCore/qdir.h:107:21: error: expected '}'
               Unsorted    = 0x03,
               ^
/usr/include/X11/X.h:540:19: note: expanded from macro 'Unsorted'
#define Unsorted                0
                                ^
/usr/include/QtCore/qdir.h:104:19: note: to match this '{'
    enum SortFlag { Name        = 0x00,
                  ^
[... some more errors, but I think these are related to the above error ...]


6 errors generated.
make[2]: *** [CMakeFiles/Volume2.dir/OGLFrame.qt.cpp.o] Error 1
make[1]: *** [CMakeFiles/Volume2.dir/all] Error 2
make: *** [all] Error 2

我检查了 qdir.h 并且有一个右括号。但正如错误表明 X.h 中的 #define 和 enum 元素之间存在冲突。我发现了 8 年前的错误报告 ( http://code.mythtv.org/trac/ticket/1417 ),建议在 X11 header 之前包含 Qt header 。因为我自己没有包含 X.h,而是链接到 X11,所以我很确定它在这里不适用。

这就留下了如何解决这个冲突的问题?非常感谢任何帮助。

最佳答案

如果可能,请更改包含的顺序,或者在包含 qdir.h 之前执行 #undef Unsorted 以清理 x.h 的困惑

关于c++ - qdir.h 与 x.h (X11) : how to resolve? 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20175259/

相关文章:

qt - qt 4.6 应用程序可以运行的最旧的 glib 版本是什么

c++ - 如何在 Qt C++ 中动态创建和加载库

python - 从bash或python检测当前鼠标光标类型的方法

c++ - QPlainTextEdit 上的 Qt 代码编辑器 如何选项卡代码

c++ - 指向成员的指针的偏移量

c++ - BitBlt 不更新 Windows C++ API 中的 WM_PAINT

c++ - 从 MainWindow 移动到函数时替换 THIS

python - 在 Ubuntu 上使用 python MSS 库时出现 XGetImage Failed 错误

发送 X11 鼠标事件的正确方法

c++ - 在作为静态成员包含在另一个类中的类的构造函数中使用 cout