Results 1 to 1 of 1

Thread: [SOLVED]error: expected declaration specifiers before ‘namespace’

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default [SOLVED]error: expected declaration specifiers before ‘namespace’

    File name: widgets.c
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Pro file:
    Qt Code:
    1. anisha@linux-dopx:~/Desktop/notes/qt> cat qt.pro
    2. ######################################################################
    3. # Automatically generated by qmake (2.01a) Thu Sep 22 14:53:10 2011
    4. ######################################################################
    5.  
    6. TEMPLATE = app
    7. TARGET =
    8. DEPENDPATH += .
    9. INCLUDEPATH += .
    10.  
    11. # Input
    12. SOURCES += widgets.c
    13. anisha@linux-dopx:~/Desktop/notes/qt>
    To copy to clipboard, switch view to plain text mode 
    Error messages:
    Qt Code:
    1. anisha@linux-dopx:~/Desktop/notes/qt> make
    2. gcc -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../qtsdk-2010.05/qt/mkspecs/linux-g++-64 -I. -I../../../qtsdk-2010.05/qt/include/QtCore -I../../../qtsdk-2010.05/qt/include/QtGui -I../../../qtsdk-2010.05/qt/include -I. -I. -o widgets.o widgets.c
    3. In file included from ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:45:0,
    4. from ../../../qtsdk-2010.05/qt/include/QtCore/qobject.h:47,
    5. from ../../../qtsdk-2010.05/qt/include/QtCore/qabstractanimation.h:45,
    6. from ../../../qtsdk-2010.05/qt/include/QtCore/QtCore:3,
    7. from ../../../qtsdk-2010.05/qt/include/QtGui/QtGui:3,
    8. from widgets.c:12:
    9. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:51:1: warning: return type defaults to ‘int’
    10. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h: In function ‘QT_MODULE’:
    11. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:54:1: error: expected declaration specifiers before ‘namespace’
    12. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1775:1: error: expected declaration specifiers before ‘Q_DECLARE_OPERATORS_FOR_FLAGS’
    13. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1796:1: error: expected declaration specifiers before ‘class’
    14. ../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1851:2: error: expected declaration specifiers before ‘;’ token
    15. In file included from ../../../qtsdk-2010.05/qt/include/QtCore/qobject.h:47:0,
    16. from ../../../qtsdk-2010.05/qt/include/QtCore/qabstractanimation.h:45,
    17. from ../../../qtsdk-2010.05/qt/include/QtCore/QtCore:3,
    18. from ../../../qtsdk-2010.05/qt/include/QtGui/QtGui:3,
    19. from widgets.c:12:
    20. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:51:1: error: expected declaration specifiers before ‘QT_MODULE’
    21. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:55:1: error: expected declaration specifiers before ‘class’
    22. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:142:1: error: expected declaration specifiers before ‘template’
    23. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:145:1: error: expected declaration specifiers before ‘template’
    24. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:212:1: error: expected declaration specifiers before ‘Q_CORE_EXPORT’
    25. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:240:1: error: expected declaration specifiers before ‘class’
    26. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:241:1: error: expected declaration specifiers before ‘class’
    27. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:242:1: error: expected declaration specifiers before ‘class’
    28. ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:243:1: error: expected declaration specifiers before ‘class’
    To copy to clipboard, switch view to plain text mode 
    What's the point that I am missing here?


    Added after 30 minutes:


    The fault was my usage of the file name as widgets.c instead of widgets.cpp :doh:
    Last edited by TheIndependentAquarius; 22nd September 2011 at 11:02. Reason: updated contents

Similar Threads

  1. error ISO C++ forbids declaration of 'obj' with no type
    By naturalpsychic in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2011, 06:23
  2. Replies: 2
    Last Post: 10th October 2010, 16:38
  3. Error::defined after prior declaration as dllimport:
    By hasnatzaidi in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2009, 01:37
  4. error: forward declaration of 'struct QPushButton'
    By prykHetQuo in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2009, 23:20
  5. Forward Class declaration ERROR
    By nleverin in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2007, 08:35

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.