【发布时间】:2011-06-15 02:15:00
【问题描述】:
我收到一个错误(“无法转换.....”),我认为 pthread_create 调用中的第三个参数是错误的。我知道第三个参数的类型应该是 (void*)*(void *) 但我仍然收到错误。
void ServerManager::Init(){
pthread_t thread;
pthread_create(&thread, NULL, AcceptLoop, (void *)this);
}
我已经这样声明了,我正在尝试调用下面的函数
void* ServerManager::AcceptLoop(void * delegate){
}
请告诉我如何解决这个问题..
提前致谢。
【问题讨论】:
-
这已经被问过很多次了:stackoverflow.com/questions/1151582/… 和其他人,我敢肯定。
-
@Adam:我想赞成你的答案,但它使用了 C 风格的演员表,必须死。否则你的答案是正确的。