Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Moved] Wierd ISO C++ forbids delaration with no type error
Forum Updated to NodeBB v4.3 + New Features

[Moved] Wierd ISO C++ forbids delaration with no type error

Scheduled Pinned Locked Moved C++ Gurus
11 Posts 5 Posters 8.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #2

    You are certainly missing a closing brace for your class. Also, what compiler is this?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      poporacer
      wrote on last edited by
      #3

      Opps, I cut the irrelevant code out and accidently cut out the closing brace and semicolon. I am using the QT Creator compiler, mingw?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        linoux
        wrote on last edited by
        #4

        It looks like the compiler doesn't recognize StartPage as a class. Maybe you should include the header of StartPage and make sure the compiler sees it.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #5

          [quote author="poporacer" date="1295531087"]Opps, I cut the irrelevant code out and accidently cut out the closing brace and semicolon. I am using the QT Creator compiler, mingw?[/quote]

          can you please post the complete header? I think there must be some other error that leads to this one.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #6

            Your snippet works for me. So, as Gerolf stated, there must be some other error.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • P Offline
              P Offline
              poporacer
              wrote on last edited by
              #7

              I will post the complete header when I get home. I had another wierd error earlier this week where I added a button in designer and then when I ran the program it wasn't there. I tried clean qmake and then rebuild. It still didn't work. I ended up getting it to work by manually deleting all the build files....object files, make files etc and then run qmake and build. I tried it this time but it didn't work.
              Thanks for your help.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                poporacer
                wrote on last edited by
                #8

                Real strange behaviour. If I change the forward declaration to some other name and the pointer declaration to match, it works. And when I change the header file and class declaration, the compiler doesn't highlight StartPage references as not being declared. Is it possible that StartPage is a function or class in either C++ or QT? The one thing that gives me doubts is that Volker tried the snippet and all is OK. Here is the complete header.
                @#ifndef MAINWINDOW_H
                #define MAINWINDOW_H
                #include <QMainWindow>
                #include <QSettings>

                #include "address.h"
                #include "projects.h"

                //Forward declaration of classes used
                class AddressPage;
                class ProjectPage;
                class StartPage;
                namespace Ui {
                class MainWindow;

                }

                class MainWindow : public QMainWindow
                {
                Q_OBJECT

                public:
                explicit MainWindow(QWidget *parent = 0);
                ~MainWindow();

                protected:
                void changeEvent(QEvent *e);
                void closeEvent (QCloseEvent *event);

                private:
                Ui::MainWindow *ui;
                ProjectPage *project;
                AddressPage *address;
                StartPage *startPage;
                void writeSettings();
                void readSettings() ;
                int idAddress;
                int idProject;
                QSettings *mSettings;

                signals:
                void restoreAddressCombo(int);
                void cmbAddressChange(int);
                void restoreProjectCombo(int);

                private slots:
                void on_btnSection_clicked();
                };

                #endif // MAINWINDOW_H
                @
                I tried this on another computer and got the same error. Any ideas?
                I am think I might just rename my class and all references. But I would like to know why it had the problem.
                Thanks a bunch. Any Ideas?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #9

                  Seems to be a problem with these two includes:

                  @
                  #include "address.h"
                  #include "projects.h"
                  @

                  I have to comment them, because they are not on my computer. The file compiles without errors here.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #10

                    And as both are not used inside this header file, they should anyway not be included here...

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      poporacer
                      wrote on last edited by
                      #11

                      I moved the headers, and I found that the problem might lie in the classes. They reference some classes that also use winserialport.h and other classes. I think there might be a class that uses startpage so I changed the class name and the associated files and all is well. Now I ran accross another problem. But I will start a new post. I am not sure if it should be in QT or here in C++ I think it should go in QT as the error references a qt file.

                      Thanks for your help.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved