You are not logged in.

1

Wednesday, March 10th 2010, 8:46am

Including QDebug throws up compile time error in QLocale

Hi - first post here ...
So I'm writing my first major Qt app. Everything is going okay - the whole application compiles fine but I'm not sure everything is working perfectly so I want to put some qDebug statements in there to check on some things. However, when I try to compile with <QDebug> included I get the following compile time errors:

Quoted

from ../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/io/qtextstream.h:48,
from ../../Qt/2010.02.1/qt/include/QtCore/qtextstream.h:1,
from ../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/io/qdebug.h:50,
from ../../Qt/2010.02.1/qt/include/QtCore/qdebug.h:1,
from QDriverThread.h:15,
from QDriverThread.cpp:8:
In file included from ../../Qt/2010.02.1/qt/include/QtCore/qlocale.h:1,
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:123: error: expected identifier before numeric constant
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:123: error: expected '}' before numeric constant
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:123: error: expected unqualified-id before numeric constant
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:548: error: expected unqualified-id before ')' token
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:549: error: expected unqualified-id before 'const'
../../Qt/2010.02.1/qt/include/QtCore/../../src/corelib/tools/qlocale.h:549: error: expected ')' before 'const'
There's a lot more qlocale.h errors after that but all of the same flavour. When I comment out my qDebugs and the #include <QDebug> everything compiles fine. I'm not doing anything locale specific BTW and don't include QLocal directly myself. I'm running under Windows XP, Qt 4.6 with MinGW as my tool set in NetBeans 6.8 IDE. Any suggestions?

Thanks

James

2

Wednesday, March 10th 2010, 10:17am

try to include othe library.
quote from Assistant

Quoted

If you include <QtDebug>, a more convenient syntax is also available:
qDebug() << "Brush:" << myQBrush << "Other value:" << i;

This post has been edited 1 times, last edit by "zamnach" (Mar 10th 2010, 10:34am)


3

Wednesday, March 10th 2010, 1:25pm

That seemed to work at first. I had included <QtCore/QtDebug> in one source file (QGraphWidget.cpp) - but then I put it in a header file for a different source file (QDriverThread.h) when it's in the header file I get the qlocale.h errors again on compilation.

4

Wednesday, March 10th 2010, 1:51pm

I had the following heierarchy of includes:

QGraphWidget.cpp
includes:
QGraphWidget.h
includes:
QDriverThread.h

QDriverThread.cpp
includes:
QDriverThread.h

It seemed that if I included QtDebug in either QDriverThread.h or .cpp I got the errors. QDriverThread also includes: <QThread> and <QMutex> and a couple of other headers of my own which just define some non-Qt classes. I discovered that if I include QtDebug BEFORE QThread and QMutex in the QDriverThread.h then everything compiles fine. However if I include it AFTER, I get the error. Weird - anyway, it seems to have solved the problem for now but I'd like to know what caused it for future reference.

James

5

Wednesday, March 10th 2010, 2:07pm

do you use 'include guard' in your code?
(http://en.wikipedia.org/wiki/Include_guard)

6

Thursday, March 11th 2010, 2:30pm

I do religously include-guard.

7

Thursday, March 11th 2010, 4:45pm

could you please create a simple example with qDebug for check?

krsmichael

Trainee

Posts: 62

Location: California

Occupation: Software Engineer

  • Send private message

8

Friday, March 12th 2010, 2:27pm

The error is probably in your code. Do you have a user written include file before the QT headers? Did you remember the ; at the end of the last thing you defined? Do you have enough #endifs?

if you want an answer, I second zamnach's request for a min file showing the problem

Rate this thread