PDA

View Full Version : Project suddenly doesn't compile



vieraci
20th November 2009, 06:55
I got a strange error when I was creating another form:

ui_productsdialog.h:132: error: expected unqualified-id before ‘namespace’
productsdialog.cpp:91: error: expected `}' at end of input
I couldn't figure out what was causing it as it seemed like the .ui file was corrupt or something, so I tried to clean the project and stared a new build, that's when hell broke loose. Now I get this error cropping up everywhere, I don't know what is causing it, this is the output:

Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/vince/projects/Qt/darwin-books'
/usr/bin/uic-qt4 findAnyRecordDialog.ui -o ui_findAnyRecordDialog.h
/usr/bin/uic-qt4 transactiondialog.ui -o ui_transactiondialog.h
/usr/bin/uic-qt4 clientdetailsdialog.ui -o ui_clientdetailsdialog.h
/usr/bin/uic-qt4 creditcarddialog.ui -o ui_creditcarddialog.h
/usr/bin/uic-qt4 despatchrecorddialog.ui -o ui_despatchrecorddialog.h
/usr/bin/uic-qt4 driverslicensedialog.ui -o ui_driverslicensedialog.h
/usr/bin/uic-qt4 cashregisterdialog.ui -o ui_cashregisterdialog.h
/usr/bin/uic-qt4 printdialog.ui -o ui_printdialog.h
/usr/bin/uic-qt4 lookupproductdialog.ui -o ui_lookupproductdialog.h
/usr/bin/uic-qt4 productsdialog.ui -o ui_productsdialog.h
/usr/bin/uic-qt4 productdialog.ui -o ui_productdialog.h
/usr/bin/uic-qt4 lookupentitydialog.ui -o ui_lookupentitydialog.h
/usr/bin/uic-qt4 creditreturnsdialog.ui -o ui_creditreturnsdialog.h
/usr/bin/uic-qt4 addressdialog.ui -o ui_addressdialog.h
/usr/bin/uic-qt4 savedbchangesdialog.ui -o ui_savedbchangesdialog.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -Iplugins/DbComboBoxExtension -I. -I. -o main.o main.cpp
In file included from clientdetailsdialog.h:11,
from transactiondialog.h:10,
from MainWindow.h:9,
from main.cpp:13:
addressdialog.h:8: error: expected unqualified-id before ‘namespace’
addressdialog.h:32: error: ISO C++ forbids declaration of ‘AddressDialog’ with no type
addressdialog.h:32: error: invalid use of ‘::’
addressdialog.h:32: error: expected ‘;’ before ‘*’ token
In file included from transactiondialog.h:10,
from MainWindow.h:9,
from main.cpp:13:
clientdetailsdialog.h:15: error: expected unqualified-id before ‘namespace’
clientdetailsdialog.h:109: error: ISO C++ forbids declaration of ‘ClientDetailsDialog’ with no type
clientdetailsdialog.h:109: error: invalid use of ‘::’
clientdetailsdialog.h:109: error: expected ‘;’ before ‘*’ token
In file included from transactiondialog.h:11,
from MainWindow.h:9,
from main.cpp:13:
cashregisterdialog.h:7: error: expected unqualified-id before ‘namespace’
cashregisterdialog.h:22: error: ISO C++ forbids declaration of ‘CashRegisterDialog’ with no type
cashregisterdialog.h:22: error: invalid use of ‘::’
cashregisterdialog.h:22: error: expected ‘;’ before ‘*’ token
In file included from transactiondialog.h:12,
from MainWindow.h:9,
from main.cpp:13:
lookupproductdialog.h:8: error: expected unqualified-id before ‘namespace’
lookupproductdialog.h:26: error: ISO C++ forbids declaration of ‘LookupProductDialog’ with no type
lookupproductdialog.h:26: error: invalid use of ‘::’
lookupproductdialog.h:26: error: expected ‘;’ before ‘*’ token
In file included from transactiondialog.h:13,
from MainWindow.h:9,
from main.cpp:13:
lookupentitydialog.h:9: error: expected unqualified-id before ‘namespace’
lookupentitydialog.h:26: error: ISO C++ forbids declaration of ‘LookupEntityDialog’ with no type
lookupentitydialog.h:26: error: invalid use of ‘::’
lookupentitydialog.h:26: error: expected ‘;’ before ‘*’ token
In file included from MainWindow.h:9,
from main.cpp:13:
transactiondialog.h:17: error: expected unqualified-id before ‘namespace’
transactiondialog.h:38: error: ISO C++ forbids declaration of ‘TransactionDialog’ with no type
transactiondialog.h:38: error: invalid use of ‘::’
transactiondialog.h:38: error: expected ‘;’ before ‘*’ token
In file included from printdialog.h:3,
from MainWindow.h:11,
from main.cpp:13:
ui_printdialog.h:132: error: expected unqualified-id before ‘namespace’
main.cpp:91: error: expected `}' at end of input
ui_printdialog.h:128: error: expected unqualified-id at end of input
make: Leaving directory `/home/vince/projects/Qt/darwin-books'
make: *** [main.o] Error 1
Exited with code 2.
Error while building project darwin-books
When executing build step 'Make'

squidge
20th November 2009, 08:01
Post some code

Plus, don't you use source control? If so, just ask it for the list of changes. SC is invaluable for this alone.

vieraci
20th November 2009, 09:05
Post some code

Plus, don't you use source control? If so, just ask it for the list of changes. SC is invaluable for this alone.

No, I haven't setup any versioning, I prefer to do manual backups myself. Anyhow, the project hasn't been rebuilt for months so I don't know if it would help.

Here is som code, they're all pretty much similar, automatically generated by Qt Creator with a few manual additions.

#ifndef ADDRESSDIALOG_H
#define ADDRESSDIALOG_H

#include <QtGui/QDialog>
#include <QSqlQuery>
#include "globaldatainstance.h"

namespace Ui {
class AddressDialog;
}

class AddressDialog : public QDialog {
Q_OBJECT
public:
AddressDialog(QWidget *parent = 0);
~AddressDialog();
void setAddressType(QString index);
void setAddressText(QString text);
void setAreacode(QString areaCode);
void setLocaleText(QString text);
QString getAddress();
QString getAddressTypeText();
QString getAddressType();
QString getAreacode();
QString getLocale();

protected:
void changeEvent(QEvent *e);
bool eventFilter(QObject *obj, QEvent *ev);

private:
Ui::AddressDialog *m_ui;
QString currentLocalesText;
void initForm();
void processEnterEvent();
// Database data for access everywhere...
GlobalDataInstance *globalData;

private slots:
void on_pbCancel_clicked();
void on_pbOK_clicked();
};

#endif // ADDRESSDIALOG_H



#ifndef TRANSACTIONDIALOG_H
#define TRANSACTIONDIALOG_H
#include <QMenuBar>
#include <QtGui/QDialog>
#include <QStatusBar>
#include <QStatusTipEvent>
#include <QtSql>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include "clientdetailsdialog.h"
#include "cashregisterdialog.h"
#include "lookupproductdialog.h"
#include "lookupentitydialog.h"
#include "transactionitemsmodel.h"
#include "globaldatainstance.h"

namespace Ui {
class TransactionDialog;
}

class TransactionDialog : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(TransactionDialog)
public:
// explicit TransactionDialog(QWidget *parent = 0);
explicit TransactionDialog(QWidget *parent = 0, QString anID="");
virtual ~TransactionDialog();
public slots:
... lots of variables and methods follow...



#ifndef MainWindow_H
#define MainWindow_H
#include <QMainWindow>
#include <QLabel>
#include <QCloseEvent>
#include "findAnyRecordDialog.h"
#include "productdialog.h"
#include "productsdialog.h"
#include "transactiondialog.h"
#include "getuseriddialog.h"
#include "printdialog.h"
#include "globaldatainstance.h"

class FindAnyRecordDialog;
class GetUserIdDialog;
class QMdiArea;

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();

protected:
void closeEvent(QCloseEvent *event);
// blah blah blah...

phillip_Qt
20th November 2009, 09:26
Try to give the relative path, like

#include<QtCore/QSqlQuery>

wysota
20th November 2009, 09:33
I would guess you forgot to close a bracket or forgot about a semicolon in a file which is included just before your "faulty" ui_productsdialog.h file.

Lykurg
20th November 2009, 09:36
Try to give the relative path, like

#include<QtCore/QSqlQuery>

QSqlQuerry is in the QtSql module and show us your globaldatainstance.h, there is probably a syntax error.

Lykurg
20th November 2009, 09:37
QSqlQuerry is in the QtSql module and show us your globaldatainstance.h, there is probably a syntax error.

EDIT: too late...

ARGH, and that should be an edit not a "post Reply":o

vieraci
20th November 2009, 10:04
I don't think there's a missing "}" anywhere because it's occurring on code that's been working for months.

Here's the code for globaldatainstance.h
It too has been working for months and I can't see any errors in it...

#ifndef GLOBALDATAINSTANCE_H
#define GLOBALDATAINSTANCE_H

#include <QtSql/QSqlQuery>

class GlobalDataInstance
{
public:
static GlobalDataInstance* Instance();
QStringList getCatItems(int cat_code, int start, int end, bool concatentReturnCode);
QString getCurrentUserName();
QString getCurrentUserId();
QString getCurrentUserAccessLevel();
void setCurrentUserName(QString);
void setCurrentUserId(QString);
void setCurrentUserAccessLevel(QString);
void clearUser();
bool refreshCatCodes();
protected:
GlobalDataInstance();
GlobalDataInstance(const GlobalDataInstance&);
GlobalDataInstance& operator= (const GlobalDataInstance&);
private:
// hmmmmmmm...static....what is it .. really ??
static GlobalDataInstance* pinstance;
// QSqlQuery is NOT a static member, but retains it's data !
QSqlQuery categoryCodes;
// These QString values are static members, must find out some time later if they really need be.
static QString currentUserName;
static QString currentUserId;
static QString currentUserAccessLevel;
};

#endif // GLOBALDATAINSTANCE_H

wysota
20th November 2009, 12:24
What about other files? I'm almost sure there is a semi-colon missing after a class declaration in one of your files. You have to check them all.

squidge
20th November 2009, 13:22
The first error is at ui_productsdialog.h:132 according to your first message, and since you didn't post that much of that file, I don't see how we can fix it for you. Maybe attach the files to a message rather than pasting them in the text?

vieraci
20th November 2009, 13:35
What about other files? I'm almost sure there is a semi-colon missing after a class declaration in one of your files. You have to check them all.

Well, that's what you'd think, but not so.
I removed the last dialog I created from the project and everything came good.
I then restored the dialog files and removed all the extra code I added to the .h and .cpp files generated, problem returned.
I come to the conclusion that something has gone corrupt in the .ui file, but a scan of it doesn't reveal anything obvious, even deleting objects and rebuilding still would not compile. I remember seeing this once before. Deleting the files and recreating them from new cleared the problem but I don't know where the problem lies, here is the corrupt(?) .ui file, maybe you can see if it builds for you ?


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProductsDialog</class>
<widget class="QDialog" name="ProductsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>578</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string>QLineEdit{
background-color: rgb(255, 255, 235);
border: 1px solid gray;
border-radius: 3px;
}

QGroupBox {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #E0E0E0, stop: 1 #FFFFFF);
border: 1px solid gray;
border-radius: 5px;
margin-top: 1ex; /* leave space at the top for the title */
}

QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left; /* position at the top center */
padding: 0 3px;
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Show</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_10">
<property name="text">
<string>&amp;All Records</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_11">
<property name="text">
<string>A&amp;vailable</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_12">
<property name="text">
<string>&amp;In Stock</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_13">
<property name="text">
<string>A&amp;llocated</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_14">
<property name="text">
<string>Lo&amp;w Stock</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_15">
<property name="text">
<string>&amp;To Order</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_16">
<property name="text">
<string>O&amp;n Back-Order</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_17">
<property name="text">
<string>&amp;Discontinued</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTableView" name="tableView"/>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Refresh - F8</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Cancel - Esc</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Clear - F9</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Help - F1</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

vieraci
20th November 2009, 13:43
The first error is at ui_productsdialog.h:132 according to your first message, and since you didn't post that much of that file, I don't see how we can fix it for you. Maybe attach the files to a message rather than pasting them in the text?

Yes that's correct, that's the file that created this problem, and it was a generated file too!
I didn't think there could be an error in a generated file, so I didn't post it. It's possible I've uncovered a bug with the GUI builder itself.

wysota
20th November 2009, 16:30
Why do you change generated files manually? Didn't you see a warning not to do that?

vieraci
20th November 2009, 22:35
Why do you change generated files manually? Didn't you see a warning not to do that?

Of course ! Not the ui file, the .h and .cpp files that get generated.

wysota
21st November 2009, 00:03
Not the ui file, the .h and .cpp files that get generated.

Which still means you are modifying generated files.

Jerome___
7th June 2016, 05:15
Which still means you are modifying generated files.

:confused:

Subject is old, but steal present (and i not see any resolved solution). :mad:
Im' very surprise by the answer of a "certified Nokia Dev ofQt framework". Like other guys, i'm surprise because .h and .cpp files are automatically generated but have to be modified for construct something more than "just a GUI design without functionality".
So, this is that every-body do currently when they make job: modify .h and .cpp files from generated QtDesigner IDE tool. :cool:

I also hope to know if this problem has been resolved or not, and how. :rolleyes:
I can see other place that this error is typaclly an error who can be from other files never show by the error... other people had similar problems.

But now currently, i use git versionning, and look at last commit to point the error... i can not see any.
Then i remove last files/class/QDialog created to see if the erorr disapear... but not !
Also, the error, same has vince, is on a file/QWidget who has always worked parfectly before this day, and there is no change on that file too...

There is sure a reason from somewhere, but not from file who never been change before the error happens... and the best idea for QT devs should be to try to find instead of lie on facts: .h and .cpp files has to be modified for use Qt framework (not ui_...h file for sure... but no one do that here, so tis is unrelevent and never resolve the problem).

So... @vince, if you steal use Qt, did you find a solution and would you like to share it with us here please ?
And other who know things,did you have an idea around this kind of typed error ?

thanks for help and share your knows.

Added after 1 4 minutes:

Find the solution and the explication of this kind of typic problem:
Some compilers never point the origin of problem for some spécifics errors.
You steal need to look at class creation definition, mine was an unrelated file who has end of definition class "};" removed (cats on the desktop runing on keyboard...).
so... because of one class miss end of declaration "};", an other strange error (where some other people had to figth with allready) occurs.

Definitely nothing to do with ui_XXXXX.h file who has not moved at all, or with modified as normal use from devs .h and .cpp linked files.
Also, have a git/svn or other versionning tool should help for point these kind of error that some compilers are not able to show the origin. (oher people had same problem and share that, compiled with clang will show the real origin of the bug).

The technic for debugging this for me was also to use a good tools for search track files content (mine was free reggexer on linux) for point related headers files who used this class (or file where this class is declared) the compiler is talking about. Then, you will have all files who call or use this class, and for sure, the problem is inside one of these files... and same i could see on other blog/dicuss, every body has same kind of missing end of definition class "};" or ";" somewhere in header files.

Thanks for sharing.

anda_skoa
7th June 2016, 07:12
Like other guys, i'm surprise because .h and .cpp files are automatically generated but have to be modified for construct something more than "just a GUI design without functionality".

Generated files are never modified, it is also never necessary.



So, this is that every-body do currently when they make job: modify .h and .cpp files from generated QtDesigner IDE tool. :cool:

Nobody ever does that.
Also designer doesn't create .h or .cpp files, it writes to .xml files.
UIC can be used to generated code from that and put it into a .h file.

Cheers,
_