PDA

View Full Version : Apparent error in QtCore/quuid.h



cwp500
18th December 2008, 11:42
Hi,
I've been working on an application in Qt 3.3 and I've just upgraded to 4.4. When I now make my app I get the following error message:


make -fMakefile.multi_meter.unx
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.4.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.4.3/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.4.3/include -I../../libbaptools/src -I/usr/X11R6/include -I. -I. -o obj_unix/meterwindow.o meterwindow.cpp
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: expected `)' before ‘-’ token
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: expected ‘,’ or ‘...’ before ‘-’ token
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: expected identifier before numeric constant
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: expected ‘,’ or ‘...’ before numeric constant
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: ISO C++ forbids declaration of ‘uchar’ with no type
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: declaration of ‘int QUuid::uchar(int)’
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/qglobal.h:788: error: changes meaning of ‘uchar’ from ‘typedef unsigned char uchar’
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: ISO C++ forbids declaration of ‘uchar’ with no type
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:89: error: expected ‘;’ before ‘b3’
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:104: error: expected `;' before ‘QUuid’
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:174: error: ‘uchar’ does not name a type
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h: In constructor ‘QUuid::QUuid()’:
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:87: error: ‘data4’ was not declared in this scope
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h: In member function ‘bool QUuid::operator==(const QUuid&) const’:
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:119: error: ‘data4’ was not declared in this scope
/usr/local/Trolltech/Qt-4.4.3/include/QtCore/quuid.h:119: error: ‘const struct QUuid’ has no member named ‘data4’
make: *** [obj_unix/meterwindow.o] Error 1



I'm guessing there's some incompatibility between my code and Qt4.4 but it still seem an odd set of error messages. Does anyone have any ideas what the problem is from these messages?
Thanks
Chris

cwp500
18th December 2008, 11:44
Oh and I'm running it on openSUSE 10.2 and Mac OSX 10.4. I get the same issues on both.

wysota
18th December 2008, 12:11
What's the contents of your qmake project file? Could you also try reordering include statements so that Qt includes come first? Such errors are often results of some namespace clash.

caduel
18th December 2008, 12:14
The error is in all probability some macro (preprocessor) that is not as you expect.
Use the -E switch to get the g++ output after preprocessing. Locate the line causing the error and you should be able to trace the real cause of the issue.

HTH

cwp500
18th December 2008, 12:16
cheers, i've tried switching round the includes before but it doesn't seem to do anything


#include <QObject>
#include <QString>
#include <QMessageBox>
#include <QGLFormat>
#include "meterwindow.h"
#include "portaudio.h"
#include <iostream>
using namespace std;

this is the qmake .pro file

TARGET = multi_meter

#CONFIG += debug
QT += opengl

include (portaudio.pri)
include (libbaptools.pri)
include (baptools.pri)



HEADERS += meterwindow.h \
qt_bendyloudness.h \
device_setup_widget.h \
config_widget.h \
device_list.h \
device.h \
signal_monitor.h \
mode_sel_but.h \
input_sel_but.h \
sampledrop.h


SOURCES += multichan_meter.cpp \
meterwindow.cpp \
qt_bendyloudness.cpp \
device_setup_widget.cpp \
config_widget.cpp \
device_list.cpp \
device.cpp \
signal_monitor.cpp \
mode_sel_but.cpp \
input_sel_but.cpp\
sampledrop.cpp


this is the included baptools.pri which is the only one of those three files that contains any QT stuff.


TEMPLATE = app
CONFIG += qt warn_on rtti

#
# set Makefile and include directories
#
macx {
MAKEFILE = Makefile.$${TARGET}.osx
QMAKE_MACOSX_DEPLOYMENT_TARGET=10.3
# To avoid weak symbol mismatch errors when building with static libraries
message( Adding linker flag "-weak_reference_mismatches non-weak")
QMAKE_LFLAGS += -weak_reference_mismatches non-weak
} else {
unix {
MAKEFILE = Makefile.$${TARGET}.unx
}
win32 {
MAKEFILE = Makefile.$${TARGET}.win
}
}

unix: OBJECTS_DIR = ./obj_unix/
macx: OBJECTS_DIR = ./obj_macx/
win32: OBJECTS_DIR = .\\obj_win32

# optional static linking settings, invoked using 'qmake "CONFIG+=static_config" ...'
include(static_config.pri)

thanks for your help

cwp500
18th December 2008, 12:24
cheers caduel.
could you help me decipher this?


g++ -headerpad_max_install_names -weak_reference_mismatches non-weak -o multi_meter.app/Contents/MacOS/multi_meter obj_macx/loud.o obj_macx/multichan_meter.o obj_macx/meterwindow.o obj_macx/qt_bendyloudness.o obj_macx/device_setup_widget.o obj_macx/config_widget.o obj_macx/device_list.o obj_macx/device.o obj_macx/signal_monitor.o obj_macx/mode_sel_but.o obj_macx/input_sel_but.o obj_macx/sampledrop.o obj_macx/moc_meterwindow.o obj_macx/moc_qt_bendyloudness.o obj_macx/moc_device_setup_widget.o obj_macx/moc_config_widget.o obj_macx/moc_device_list.o obj_macx/moc_device.o obj_macx/moc_signal_monitor.o obj_macx/moc_mode_sel_but.o obj_macx/moc_input_sel_but.o obj_macx/moc_sampledrop.o -F/usr/local/Trolltech/Qt-4.4.3/lib -L/usr/local/Trolltech/Qt-4.4.3/lib -framework CoreAudio -framework AudioToolbox -framework QtOpenGL -L/usr/local/Trolltech/Qt-4.4.3/lib -F/usr/local/Trolltech/Qt-4.4.3/lib -framework QtGui -framework Carbon -framework AppKit -framework QtCore -lz -lm -framework ApplicationServices -framework OpenGL -framework AGL
/usr/bin/ld: obj_macx/multichan_meter.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/meterwindow.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/qt_bendyloudness.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/device_setup_widget.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/config_widget.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/device_list.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/device.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/signal_monitor.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/mode_sel_but.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/input_sel_but.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/sampledrop.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_meterwindow.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_qt_bendyloudness.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_device_setup_widget.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_config_widget.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_device_list.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_device.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_signal_monitor.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_mode_sel_but.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_input_sel_but.o bad magic number (not a Mach-O file)
/usr/bin/ld: obj_macx/moc_sampledrop.o bad magic number (not a Mach-O file)
collect2: ld returned 1 exit status
make: *** [multi_meter.app/Contents/MacOS/multi_meter] Error 1[CODE]

wysota
18th December 2008, 12:36
Could you check the contents of the offending line? I mean the 89th line of the file mentioned by the compiler. My version doesn't have any "-" characters in that line. I'd say the conflict is in the "uchar" symbol which Qt defines as a typedef to unsigned char. Do you declare such symbol somewhere?

caduel
18th December 2008, 14:13
please take the compile statement

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.4.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtCore -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include/QtGui -I/usr/local/Trolltech/Qt-4.4.3/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.4.3/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.4.3/include -I../../libbaptools/src -I/usr/X11R6/include -I. -I. -o obj_unix/meterwindow.o meterwindow.cpp

replace the -c by -E
and -o obj_unix/meterwindow.o by -o /tmp/to_check

Then find the line "89" in quuid.h in that file. There will be some error. The error will be that something has been broken by some (unexceptedly) defined macro, e.g.
a #define uchar "some bogus text".
If you can not decipher the contents, show it to us.

cwp500
18th December 2008, 15:59
Hi,
I've been trying to sort it out but no luck.
Line 89 looks fine in quuid.h


enum Version {
VerUnknown =-1,
Time = 1, // 0 0 0 1
EmbeddedPOSIX = 2, // 0 0 1 0
Name = 3, // 0 0 1 1
Random = 4 // 0 1 0 0
};

QUuid()
{
data1 = 0;
data2 = 0;
data3 = 0;
for(int i = 0; i < 8; i++)
data4[i] = 0;
}
QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) // this is line 89
{
data1 = l;
data2 = w1;
data3 = w2;
data4[0] = b1;
data4[1] = b2;
data4[2] = b3;
data4[3] = b4;
data4[4] = b5;
data4[5] = b6;
data4[6] = b7;
data4[7] = b8;
}
#ifndef QT_NO_QUUID_STRING

as does the code around it.

When I run the compile command with the -E flag, there is no error and the output file contains 70000 lines. i don't know how to begin with it. that's on openSUSE. on my mac it seems to have failed to find any of the Qt header files even though their directories are linked in the g++ command.
sorry this doesn't give you much but do you have any other suggestions?

caduel
18th December 2008, 17:58
you have to search in that 70000 lines of code (which are what the compiler has to digest once the preprocessor is done) for your line...

you can do that in three ways:
1) just try to compile that file
2) use the file/line info (quuid.h, 89) to find that line in that (big) file.
Look for lines like

# 5 "path_to_your_qt_includes/quuid.h" 2
this means: this line correspondends to line 5 in the file quuid.h; if no more file should be included, go 84 lines further and you have found that spot
3) look into quuid.h, close to line 89; find some probably "unique" code (no macros!) and just search the big file for it
[4) post the file here as attachment... we will find out]

HTH

cwp500
18th December 2008, 18:49
I found the offending item. In one of my code files I had included <QtOpenGL> as in one of the example files. When I changed this for the specific classes I need it worked fine.
Thanks for the help guys.

wysota
18th December 2008, 20:51
It shouldn't have caused you problems...