[Qt-interest] Strange conflict with QWidget and X11/Xutil.h
Pau Garcia i Quiles
pgquiles at elpauer.org
Mon Aug 31 11:12:10 CEST 2009
On Mon, Aug 31, 2009 at 12:52 AM, Chris<chris1.noreply at googlemail.com> wrote:
> Hi,
>
> I've been stuck with a compilation problem in my latest project for a
> long time and I've whittled it down to this short snippet (main.cpp):
>
> #include <QApplication>
> #include <QWidget>
> #include <X11/Xutil.h>
> int main(int argc, char *argv[])
> {
> QApplication app(argc, argv);
> return app.exec();
> }
>
> I'm running Fedora 11 (qt-4.5.2-2) and if I build this I get:
>
> g++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586
> -mtune=generic -fasynchronous-unwind-tables -Wall -W -D_REENTRANT
> -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
> -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore
> -I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.cpp
> In file included from /usr/include/QtCore/qstringlist.h:46,
> from /usr/include/QtGui/qcolor.h:47,
> from /usr/include/QtGui/qpalette.h:46,
> from /usr/include/QtGui/qwidget.h:48,
> from /usr/include/QtGui/QWidget:1,
> from main.cpp:4:
> /usr/include/QtCore/qdatastream.h:49:2: error: #error qdatastream.h
> must be included before any header file that defines Status
> In file included from /usr/include/QtCore/qstringlist.h:46,
> from /usr/include/QtGui/qcolor.h:47,
> from /usr/include/QtGui/qpalette.h:46,
> from /usr/include/QtGui/qwidget.h:48,
> from /usr/include/QtGui/QWidget:1,
> from main.cpp:4:
> /usr/include/QtCore/qdatastream.h:98: error: expected identifier before ‘int’
> /usr/include/QtCore/qdatastream.h:98: error: expected unqualified-id
> before ‘{’ token
> /usr/include/QtCore/qdatastream.h: In function ‘QDataStream&
> operator>>(QDataStream&, QHash<Key, T>&)’:
> /usr/include/QtCore/qdatastream.h:338: error: expected unqualified-id
> before ‘int’
> /usr/include/QtCore/qdatastream.h:338: error: expected ‘;’ before ‘int’
> /usr/include/QtCore/qdatastream.h:346: error: ‘Ok’ is not a member of
> ‘QDataStream’
> /usr/include/QtCore/qdatastream.h:355: error: ‘Ok’ is not a member of
> ‘QDataStream’
> /usr/include/QtCore/qdatastream.h:357: error: ‘oldStatus’ was not
> declared in this scope
> /usr/include/QtCore/qdatastream.h:357: error: ‘Ok’ is not a member of
> ‘QDataStream’
> /usr/include/QtCore/qdatastream.h: In function ‘QDataStream&
> operator>>(QDataStream&, QMap<aKey, aT>&)’:
> /usr/include/QtCore/qdatastream.h:382: error: expected unqualified-id
> before ‘int’
> /usr/include/QtCore/qdatastream.h:382: error: expected ‘;’ before ‘int’
> /usr/include/QtCore/qdatastream.h:392: error: ‘Ok’ is not a member of
> ‘QDataStream’
> /usr/include/QtCore/qdatastream.h:401: error: ‘Ok’ is not a member of
> ‘QDataStream’
> /usr/include/QtCore/qdatastream.h:403: error: ‘oldStatus’ was not
> declared in this scope
> /usr/include/QtCore/qdatastream.h:403: error: ‘Ok’ is not a member of
> ‘QDataStream’
> make: *** [main.o] Error 1
>
> I can probably find a way around it (by avoiding X11util.h) but should
> I report a bug or does anyone have any idea why this might happen?
In KDE we fix that kind of bugs by including fixx11h.h
http://websvn.kde.org/trunk/KDE/kdelibs/kdeui/util/fixx11h.h?&view=markup
As Girish says, it's odd that it happens when you include X headers
after Qt headers, though.
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
More information about the Qt-interest-old
mailing list