[Qt-interest] Strange conflict with QWidget and X11/Xutil.h
Girish Ramakrishnan
girish at forwardbias.in
Mon Aug 31 08:58:29 CEST 2009
Strange, I have seen this problem only when including X headers before
Qt headers. Code below compiles fine on my ubuntu g++ 4.3.3, btw. If I
move the X include to be before Qt, I see the same errors as yours.
Girish
Chris 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?
>
> Cheers, Chris.
More information about the Qt-interest-old
mailing list