Results 1 to 13 of 13

Thread: what does this mean " error: ISO C++ forbids declaration of --- with no type?

  1. #1
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default what does this mean " error: ISO C++ forbids declaration of --- with no type?

    HI
    i am getting this error "error: ISO C++ forbids declaration of ‘-----’ with no type"
    when do we get this error ??

    Thnkx in advance...

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    Post some code.

  3. #3
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    Most likely you forgot a necessary forward declaration or include.

  4. #4
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    @fatjuicymole
    mainwindow.h file.. i am getting the error in this code.
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QThread>
    5. #include <QMessageBox>
    6.  
    7. #include <QtGui/QMainWindow>
    8.  
    9. #include "sampleThread.h"
    10.  
    11.  
    12. namespace Ui
    13. {
    14. class MainWindow;
    15. }
    16.  
    17. class MainWindow : public QMainWindow
    18. {
    19. Q_OBJECT
    20.  
    21. public:
    22. MainWindow(QWidget *parent = 0);
    23. ~MainWindow();
    24.  
    25.  
    26. private:
    27. Ui::MainWindow *ui;
    28.  
    29. sampleThread *newThread;//in this line
    30. };
    31.  
    32. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by qtlinuxnewbie; 29th April 2010 at 13:12.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    What is the contents of sampleThread.h?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    Qt Code:
    1. #ifndef SAMPLETHREAD_H
    2. #define SAMPLETHREAD_H
    3. #include <QMessageBox>
    4. #include <QThread>
    5.  
    6. #include "mainwindow.h"
    7.  
    8. class sampleThread:public QThread
    9. {
    10.  
    11. public:
    12.  
    13. sampleThread();
    14. void run();
    15. QWidget *targetWidget;
    16.  
    17. };
    18.  
    19.  
    20. #endif // SAMPLETHREAD_H
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default

    Your thread class in sampleThread.h... Is it really named 'Thread' or 'SampleThread' or 'sampleThread'.... The compiler does not know your 'Tread'.

    Interrupted by a colleague. :-)

    Try: samleThread *newThread;
    Last edited by wysota; 29th April 2010 at 09:58.

  8. #8
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    actually it is sampleThread only

  9. #9
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    Quote Originally Posted by qtlinuxnewbie View Post
    actually it is sampleThread only
    ??? Pardon? I don't understand.

    It is either:
    QThread *newThread;
    or:
    sampleThread *newThread;

    You don't have a class 'Thread'.

  10. #10
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    may be i was not clear for u .
    it is
    Qt Code:
    1. sampleThread *newThread
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    In the code you have posted, you use just "Thread", not "sampleThread".

  12. #12
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    i changed the posted code to sampleThread and tried to build but i am getting the same error.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?

    You have a loop in your includes - mainwindow.h includes sampleThread.h which again includes mainwindow.h. Use a forward declaration in mainwindow.h instead of including sampleThread.h or don't include mainwindow.h in the other file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 27th August 2011, 12:59
  2. forbids declaration of QHash with no type
    By nina1983 in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2008, 13:05
  3. "Treat wchar_t as Built-in Type" to "yes" link error
    By sungaoyong in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 11:45
  4. Compilation error: "field 'xxx' has incomplete type"
    By fedcer in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 15:01
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 15:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.