【发布时间】:2012-10-19 13:23:51
【问题描述】:
我正在尝试使用启动例程创建线程,但 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++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say '&myFunction'。
它无法将void (myClass::*) (void*) 转换为void* (*) (void*) 用于pthread_create 的参数3。
有什么想法吗?
【问题讨论】: