免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1083 | 回复: 1
打印 上一主题 下一主题

多线程的问题请教一下? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-08-15 17:20 |只看该作者 |倒序浏览
下面是起线程的代码:

  1. //启动每日处理线程
  2. iRet=pthread_create(&tid, NULL, &MonthlyTableProcess, (void *)(g_stpMParam[i]));
  3. if(iRet==0){//调用成功
  4. printf("succeed to create thread\n");
  5. sleep(1);
  6. }
  7. else{//调用失败
  8. printf("%d:%s\n", errno, strerror(errno));
  9. printf("Fail to create thread\n");
  10. }
复制代码

一下是调用函数的声明:
SMidtblParam和stpMP都是自定义的结构体。

  1. void MonthlyTableProcess(void* param)
  2. {
  3. //得到抽取的参数
  4. SMidtblParam* stpMP;
  5. stpMP=(SMidtblParam* )param;
  6. ………………
  7. }
复制代码


一下是编译错误的:
1540-5215 (W) No licenses available. Contact your program supplier to add additional users. Compilation will proceed shortly.
1540-5201 (W) Suboption "ppc64" for option "arch" is not supported on the target platform.
"workproduce.cpp", line 447.65: 1540-0256 (S) A parameter of type "extern "C" void *(*)(void *)" cannot be initialized with an expression of type "void *".
"workproduce.cpp", line 447.65: 1540-1205 (I) The error occurred while converting to parameter 3 of "pthread_create(pthread_t *, const pthread_attr_t *, extern "C" void *(*)(void *), void *)".

请问为什么会出错?正确的该怎么写?

论坛徽章:
0
2 [报告]
发表于 2005-08-15 17:53 |只看该作者

多线程的问题请教一下?

返回值类型错误
void* MonthlyTableProcess(void* param)
{
//得到抽取的参数
SMidtblParam* stpMP;
stpMP=(SMidtblParam* )param;
………………
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP