• 9237阅读
  • 6回复

含泪举手中,关于编译时报 error: ISO C++ forbids declaration of 。【已解决】 [复制链接]

上一主题 下一主题
离线gzfk
 
只看楼主 倒序阅读 楼主  发表于: 2010-05-09
小弟新手。

用Fc下用QT4.6.0 能正确运行
用Qt 4.6.0+ arm-linux-gcc4.1.2  交叉编译能通过 能在qvfb运行。

但是用Qtopia4.3.3 + arm-linux-gcc 3.4.1 交叉编译则报错一群群。。


arm-linux-g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/qtopiacore_ts/mkspecs/qws/linux-arm-g++ -I. -I/usr/local/Trolltech/qtopiacore_ts/include/QtCore -I/usr/local/Trolltech/qtopiacore_ts/include/QtCore -I/usr/local/Trolltech/qtopiacore_ts/include/QtNetwork -I/usr/local/Trolltech/qtopiacore_ts/include/QtNetwork -I/usr/local/Trolltech/qtopiacore_ts/include/QtGui -I/usr/local/Trolltech/qtopiacore_ts/include/QtGui -I/usr/local/Trolltech/qtopiacore_ts/include -I. -I. -I. -o main.o main.cpp
In file included from main.cpp:2:
window.hpp:8: error: expected constructor, destructor, or type conversion before "class"
window.hpp:8: error: expected `,' or `;' before "class"
window.hpp:13: error: expected constructor, destructor, or type conversion before "class"
window.hpp:13: error: expected `,' or `;' before "class"
window.hpp:31: error: ISO C++ forbids declaration of `ShowImage' with no type
window.hpp:31: error: expected `;' before '*' token
window.hpp:32: error: ISO C++ forbids declaration of `QPushButton' with no type
window.hpp:32: error: expected `;' before '*' token
window.hpp:33: error: ISO C++ forbids declaration of `QPushButton' with no type
window.hpp:33: error: expected `;' before '*' token
window.hpp:34: error: ISO C++ forbids declaration of `QPushButton' with no type
window.hpp:34: error: expected `;' before '*' token
make: *** [main.o] 错误 1

有大侠能够提示一下吗?

含泪拜谢……
[ 此帖被gzfk在2010-05-10 02:18重新编辑 ]
离线solu
只看该作者 1楼 发表于: 2010-05-09
具体出错的代码贴出来呗
离线hehui

只看该作者 2楼 发表于: 2010-05-09
error: ISO C++ forbids declaration of `ShowImage' with no type

类的名字是不是正确?
离线gzfk
只看该作者 3楼 发表于: 2010-05-09
引用第1楼solu于2010-05-09 17:37发表的 :
具体出错的代码贴出来呗


严重感激solu大侠的关注。


=============================================

#ifndef WINDOW_H
#define WINDOW_H
 
#include <QWidget>
#include <QString>

QT_BEGIN_NAMESPACE
class QPushButton;
class QFileDialog;
class QSlider;
class QLabel;
QT_END_NAMESPACE
class ShowImage;
 
class Window : public QWidget
{
    Q_OBJECT
 
public:
    Window();
 
private slots:
    void turn2next();
    void turn2prev();
    void dirChanged(QString);
    void scalethepix(int);
    void changelabel(int);
 
 =============================================
从第八行 class QPushButton; 那里开始报错。
 
不知道是不是头文件没有写全?
用Qt 4.6.0 的话,是能够编译通过的 4.3.3则不行,版本之间类的差别太大,还是小弟漏了什么导致?


.. .
离线gzfk
只看该作者 4楼 发表于: 2010-05-09
引用第2楼hehui于2010-05-09 19:37发表的  :
error: ISO C++ forbids declaration of `ShowImage' with no type
类的名字是不是正确?


谢谢hehui大侠的关注。。

代码是出自网上高人的,名字应该没有错,换用 4.6.0 和4.6.2都没有问题。。。万分苦恼ing。
离线dbzhang800

只看该作者 5楼 发表于: 2010-05-09
没用过 Qtopia

不过你不妨将那两个QT开头的宏去掉后再试试
离线gzfk
只看该作者 6楼 发表于: 2010-05-10
引用第5楼dbzhang800于2010-05-09 22:21发表的  :
没用过 Qtopia
不过你不妨将那两个QT开头的宏去掉后再试试



拜谢dbzhang 。。!

原来是这东西。啊,注释掉就可以了。

感谢!
快速回复
限100 字节
 
上一个 下一个