Important: Please read the Qt Code of Conduct -

Errors after include

  • Hello Everybody,

    I'm completly blocked at the moment :-(
    Each time I try to include my header file "communicator.h" to the header "property.h" I get the strange error below. It seams to have no relationship to my include at all.
    09:27:09: Running steps for project SaphirCube...
    09:27:09: Configuration unchanged, skipping qmake step.
    09:27:09: Starting: "/usr/bin/make" -j3 -w
    make: Entering directory /mnt/local/home/reto/Projects/Saphir_eval/pc/SaphirCube/SaphirCube-build-Desktop_Qt_5_0_1_GCC_64bit-Debug' <<all kind of working messages>> -_64/include/QtCore -I. -I. -I. -o property_dropdown.o ../SaphirCube/property_dropdown.cpp In file included from /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtPrintSupport/qprinter.h:47:0, from /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtPrintSupport/QPrinter:1, from ../SaphirCube/Plotter/qcustomplot.h:43, from ../SaphirCube/timeplotter.h:7, from ../SaphirCube/mainwindow.h:8, from ../SaphirCube/main.cpp:4: /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:63:57: error: expected identifier before numeric constant /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:63:57: error: expected '}' before numeric constant /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:63:57: error: expected unqualified-id before numeric constant /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:67:30: error: 'virtual' outside class declaration /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:67:30: error: variable or field 'setPageSize' declared void /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:67:30: error: 'PageSize' was not declared in this scope /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:68:5: error: 'PageSize' does not name a type /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:70:50: error: 'virtual' outside class declaration /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:71:25: error: non-member function 'QSizeF pageSizeMM()' cannot have cv-qualifier /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:80:51: error: 'virtual' outside class declaration /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:81:23: error: non-member function 'Margins margins()' cannot have cv-qualifier /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:83:1: error: expected unqualified-id before 'protected' /opt/Qt/Qt5.0.0/5.0.1/gcc_64/include/QtGui/qpagedpaintdevice.h:86:1: error: expected declaration before '}' token make: *** [main.o] Error 1 make: Leaving directory/mnt/local/home/reto/Projects/Saphir_eval/pc/SaphirCube/SaphirCube-build-Desktop_Qt_5_0_1_GCC_64bit-Debug'
    09:27:11: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project SaphirCube (kit: Desktop Qt 5.0.1 GCC 64bit)
    When executing step 'Make' @

    This is the included file:
    @#ifndef COMMUNICATOR_H
    #define COMMUNICATOR_H

    #include <QObject>
    #include <QString>
    #include <QList>
    #include <qextserialport.h>
    #include "QsLog.h"
    #include "command.h"

    class Communicator : public QObject
    explicit Communicator(QObject parent = 0);
    void ExecuteCommand(Command

    void got_answer(QByteArray Data);
    void got_data(QByteArray Data);

    public slots:
    void SetDevicePath(QString path);

    private slots:
    void Read();

    QextSerialPort* port;
    bool Read_busy;
    QByteArray Read_incomming;
    QList<Command*> CommandQueue;
    int RunningNr;
    void RunNext();
    QByteArray Header;

    #endif // COMMUNICATOR_H

    and the file where I want to include:
    @#ifndef PROPERTY_H
    #define PROPERTY_H

    #include <QWidget>
    #include <QHBoxLayout>
    #include <QLabel>
    #include <QPushButton>
    #include "command.h"
    #include "communicator.h" <-- Problems start as soon this line is inserted.

    class Property : public QWidget
    explicit Property(QWidget *parent = 0);
    explicit Property(QString Name, QWidget parent = 0);
    void SetName(QString Name);
    void SetRegister(int Reg);
    void SetCommunicator(Communicator

    public slots:
    virtual void Update() = 0;

    QHBoxLayout* TopLayout;
    QPushButton* btnName;
    int Register;
    Communicator* com;

    void Changed(char*, int lenght, char address);

    void Init();


    #endif // PROPERTY_H

    The file "communicator.h" has been included into the main file already without problems.

    Does somebody have a Idea what that could be or a way to find the source of this bug?
    Thank you a lot.

  • Problem Solved!

    Instead of including the file , I made a forward declaration.
    (Ok, I still have no Idea why, but it works now ;-) )


  • hmmmm... if I had to make an educated guess I would say there is a perhaps a subtle syntax issue.

    I would say its worth digging a bit deeper to find the issue so that it does not byte you in your ass later! :o

    I would try including your header with everything commented out (even the #includes), and then add parts of it back bit by bit until you see your issue again...

    Honestly, if there is a "silly little error" in there it could really be a problem later and you might not know where to look :(

Log in to reply