<分区>
Possible Duplicate:
pthread Function from a Class
我正在尝试创建一个带有启动例程的线程,但 g++ 不喜欢我的语法。
class myClass
{
void* myFunction(void* myArg)
{
// some code, useless here
}
void start()
{
pthread_t thread_id;
int* fd;
//Some code, useless here.
pthread_create(&thread_id, 0, &myFunction, (void*) fd);
}
}
在编译器期间,g++ 告诉我 ISO C++ 禁止采用未限定或带括号的非静态成员函数的地址来形成指向成员函数的指针。说“&myFunction”
。
对于 pthread_create< 的参数 3,它无法将
.void (myClass::*) (void*)
转换为 void* (*) (void*)
/
有什么想法吗?