需求如下:
1、适用类成员函数作为线程处理函数,并访问非静态的类成员。
2、在类的成员函数里起线程;
咨询组内同事并百度后解决了编译问题,特记录总结学习:
1、在.h中声明线程处理函数:
public:
static void* LoadFpga1_thread(void* a);
2、.cpp:
void* LoadFpga1_thread(void* a)
{
auto obj = static_cast<classname *>(a); //注意:dynmaic_cast编译不过
obj->member..//do something
}
caller()
{
int ret = pthread_create(&thread, NULL, calssname::LoadFpga1_thread, (classname *)this);
}