天嵌 ARM开发社区

 找回密码
 注册
查看: 1794|回复: 1

用g++ 来编译linxu的线程pthread的问题

[复制链接]
dsgh2440 发表于 2010-4-15 11:59:27 | 显示全部楼层 |阅读模式
程式內容如下:
#include <stdio.h>;
#include <pthread.h>;
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);
}
编译后报错误如下:意思是
不能从(void*)void  转换为 (void*)(*)(void*)
这是什么原因?望高人指点。
亚瑟王 发表于 2010-4-16 10:43:48 | 显示全部楼层
ret=pthread_create(&id,NULL,(void *) thread,NULL);这句话写错了。
应该是:
ret=pthread_create(&id,NULL,(void *) &thread,NULL);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-18 12:24 , Processed in 1.046875 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表