标题:求助!!
取消只看楼主
yfuy23
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2004-7-12
 问题点数:0 回复次数:2 
求助!!

高手能不能来告诉我下,这段代码为什么在linux下用g++编译不成功,而用gcc能编译成功。应该怎样修改才能用g++编译成功??

/* example.c*/ #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); }

2004-09-16 10:04
yfuy23
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2004-7-12
得分:0 

我用的是 g++ 源文件 -lpthread -o 目标文件 这条命令编译的。

给出的信息是:In function 'int main()':

invalid conversion from 'void(*)()' to 'void*(*)(void*)'

而用gcc可以编译通过。

2004-09-16 18:47
yfuy23
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2004-7-12
得分:0 

嗯,我也编译成功了,谢谢

2004-09-29 16:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-5360-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.185494 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved