- Qt的路径不支持中文
- 问题:'MyThread' does not name a type
原因:thread.h包含usbtest.h,usbtest.h包含thread.h。头文件循环引用 - 问题:class UsbTest 里Mythread thread1; 中‘MyThread’ does not name a type
原因:thread1.h包含usbtest.h, usbtest.h包含thread1.h
防止重复引用的方法就是在每个头文件中加上ifndef/define/endif条件编译语句
头文件重复引用是指一个头文件在同一个CPP文件中被INCLUDE了多次,这种错误常常是由于INCLUDE 嵌套造成的 全局变量
自定义的结构体:
(1)usbtest.h里声明extern struct libusb_device_handle 星devh;
(2)usbtest.cpp里定义struct libusb_device_handle 星devh = NULL;
(3)thread1.cpp里加#include "usbtest.h"
struct test_state {
libusb_device 星found;
libusb_context 星ctx;
libusb_device_handle 星handle;
int attached;
};
extern struct test_state state;局部变量
(1)usbtest.h里定义结构体类型
struct test_state {
libusb_device 星found;
libusb_context 星ctx;
libusb_device_handle 星handle;
int attached;
};
class UsbTest声明struct test_state state;
(2)thread1.h里class Thread1声明struct test_state 星m_state;
(3)usbtest.cpp里UsbTest的构造函数里加thread1.m_state = &state;- 变量与系统重名,加static
qt4 与 qt5的区别:pro文件里有widgets的是qt5
转载于:https://www.cnblogs.com/shawnlxf/p/7345665.html