用g++ example.c -lpthread -o example编译
怎么会出现错误 In function `int main()':
example.c:41: invalid conversion from `void*' to `void*(*)(void*)'
该怎么解决?十分感谢!!
代码如下:
void thread(void)
{
int i;
for(i=0;i<3;i++)
printf("This is a pthread.\n");
}
int main(void)
{
pthread_t id;
int i,ret;
ret=pthread_create(&id,NULL,(void *)thread,NULL);
if(ret!=0){
printf ("Create pthread error!\n");
exit (1);
}
for(i=0;i<3;i++)
printf("This is the main process.\n");
pthread_join(id,NULL);
return (0);
}