qt串口编程的问题

aaixinjue   2009-6-16 17:56 楼主
make后提示 serialthread.h 语法错误,但没发现serialthread.h中的语法错误。为什么编译不成功呢??

[root@localhost qt-1]# make

g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG
-I/working/qt/qt-2.3.7/include -o mainwindow.o mainwindow.cpp
In file included from mainwindow.cpp:12:
mainwindow.h:38:8: warning: no newline at end of file
In file included from mainwindow.cpp:13:
serialthread.h:8: parse error before `{' token
serialthread.h:12: virtual outside class declaration
serialthread.h:13: parse error before `private'
mainwindow.cpp: In member function `void MainWindow::serialOperate()':
mainwindow.cpp:39: invalid use of undefined type `class SerialThread'
mainwindow.h:10: forward declaration of `class SerialThread'
mainwindow.cpp:40: invalid use of undefined type `class SerialThread'
mainwindow.h:10: forward declaration of `class SerialThread'
mainwindow.cpp:41: invalid use of undefined type `class SerialThread'
mainwindow.h:10: forward declaration of `class SerialThread'
mainwindow.cpp:79:3: warning: no newline at end of file
make: *** [mainwindow.o] Error 1


但没发现[serialthread.h]有什么语法错误
/* serialthread.h */

#ifndef SERIAL_THREAD_H
#define  SERIAL_THREAD_H
#include

class MainWindow;

class SerialThread: public QThread
{
public:
    SerialThread(MainWindow *parent);
    virtual void run();
private:
    MainWindow *parent;

};
#endif

回复评论 (4)

这不是串口的问题,

是C++的用法问题,

头文件的定义,以及cpp文件中的引用方式可能有些问题。
点赞  2009-6-17 09:33
检查一下环境变量配置好没有?include目录,lib目录这些路径有没有设置对。
点赞  2009-6-18 15:24
解决啦,是添加多线程支持
不过还是谢谢大家!O(∩_∩)O~
点赞  2009-6-18 21:33
请问你是如何解决的,我也遇到了同样的问题。郁闷中。。。
点赞  2009-6-24 15:49
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复