pthread-凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
pthread_create函数 参数不匹配的问题
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
问题现象:
write_log_for_code.cpp:257: error:argument of type ‘void* (write_log_for_code::)(void*)’ does not match ‘void*(*)(void*)’
代码://.cpp
bool write_log_for_code::startsleepthread()
{
int ret = pthread_create(&m_tid_sleep,null,sleepfun,this);
if(ret != 0)
{
printf("create thread fail.\n");
return false;
}
return true;
}
//.h
void* sleepfun(void* arg);
原因:线程方法必须是静态方法,你如果写在类里,不能是成员函数,需要加static
改为://.h
static void* sleepfun(void* arg);
问题解决!
总结
以上是凯发k8官方网为你收集整理的pthread_create函数 参数不匹配的问题的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: