首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

一个简单的线程程序,找异常

2012-03-20 
一个简单的线程程序,找错误。C/C++ code#includestdio.h#includepthread.hint num1,num2void * mythre

一个简单的线程程序,找错误。

C/C++ code
#include<stdio.h>#include<pthread.h>int num1,num2;void * mythread(* attr){    int * num=(int *)attr;    printf("%d \n",*num);}int main(int agrc,char *argv[]){    pthread_t tid1,tid2;    int status;    num1 = 1;    num2 = 2;    status = pthread_create(&tid1,NULL,mythread,&num1);    if(status){        printf("create failed!");        return -1;    }        status = pthread_create(&tid2,NULL,mythread,&num2);    if(status){        printf("create failed!");        return -1;    }        status = pthread_join(tid1,NULL);    if(status){        printf("error!");        return -1;    }        status = pthread_join(tid2,NULL);    if(status){        printf("error!");        return -1;    }    return 0;}

gcc后提示:
pthread_join.c: In function ‘main’:
pthread_join.c:17:37: error: ‘mythread’ undeclared (first use in this function)
pthread_join.c:17:37: note: each undeclared identifier is reported only once for each function it appears in



[解决办法]
void * mythread(* attr)
不是一个函数的声明或定义

热点排行