shawn1416

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  1. Qt的路径不支持中文

  2. 问题:'MyThread' does not name a type
    原因:thread.h包含usbtest.h,usbtest.h包含thread.h。头文件循环引用

  3. 问题:class UsbTest 里Mythread thread1; 中‘MyThread’ does not name a type
    原因:thread1.h包含usbtest.h, usbtest.h包含thread1.h
    防止重复引用的方法就是在每个头文件中加上ifndef/define/endif条件编译语句
    头文件重复引用是指一个头文件在同一个CPP文件中被INCLUDE了多次,这种错误常常是由于INCLUDE 嵌套造成的

  4. 全局变量
    (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;

  5. 局部变量
    (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;

  6. 变量与系统重名,加static

  7. qt4 与 qt5的区别:pro文件里有widgets的是qt5

posted on 2017-08-16 23:13  shawn1416  阅读(170)  评论(0编辑  收藏  举报