开发者

error: expected declaration specifiers before ‘namespace’

File name: widgets.c

 #include <QtGui>

 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
     return app.exec();
 }

Pro file:

anisha@linux-dopx:~/Desktop/notes/qt> cat qt.pro
######################################################################
# Automatically generated by qmake (2.01a) Thu Sep 22 14:53:10 2011
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .

# Input
SOURCES += widgets.c
anisha@linux-dopx:~/Desktop/notes/qt> 

Error messages:

anisha@linux-dopx:~/Desktop/notes/qt> make
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
In file included from ../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:45:0,
                 fro开发者_开发问答m ../../../qtsdk-2010.05/qt/include/QtCore/qobject.h:47,
                 from ../../../qtsdk-2010.05/qt/include/QtCore/qabstractanimation.h:45,
                 from ../../../qtsdk-2010.05/qt/include/QtCore/QtCore:3,
                 from ../../../qtsdk-2010.05/qt/include/QtGui/QtGui:3,
                 from widgets.c:12:
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:51:1: warning: return type defaults to ‘int’
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h: In function ‘QT_MODULE’:
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:54:1: error: expected declaration specifiers before ‘namespace’
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1775:1: error: expected declaration specifiers before ‘Q_DECLARE_OPERATORS_FOR_FLAGS’
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1796:1: error: expected declaration specifiers before ‘class’
../../../qtsdk-2010.05/qt/include/QtCore/qnamespace.h:1851:2: error: expected declaration specifiers before ‘;’ token
In file included from ../../../qtsdk-2010.05/qt/include/QtCore/qobject.h:47:0,
                 from ../../../qtsdk-2010.05/qt/include/QtCore/qabstractanimation.h:45,
                 from ../../../qtsdk-2010.05/qt/include/QtCore/QtCore:3,
                 from ../../../qtsdk-2010.05/qt/include/QtGui/QtGui:3,
                 from widgets.c:12:
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:51:1: error: expected declaration specifiers before ‘QT_MODULE’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:55:1: error: expected declaration specifiers before ‘class’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:142:1: error: expected declaration specifiers before ‘template’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:145:1: error: expected declaration specifiers before ‘template’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:212:1: error: expected declaration specifiers before ‘Q_CORE_EXPORT’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:240:1: error: expected declaration specifiers before ‘class’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:241:1: error: expected declaration specifiers before ‘class’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:242:1: error: expected declaration specifiers before ‘class’
../../../qtsdk-2010.05/qt/include/QtCore/qobjectdefs.h:243:1: error: expected declaration specifiers before ‘class’

What's the point that I am missing here?


Looks like you are using the C Compiler to compile C++. Try renaming your file to widgets.cpp.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜