#include<pthread.h> 
#include<stdlib.h> 
#include<stdio.h>
#include<unistd.h> 
static int shdata=1; 
void *create(void *arg) 
{ printf("new phread ....\n"); 
  printf("shared data = %d \n",shdata); 
  return (void *)0; 

int main(int argc,char *argv[]) 

    pthread_t tidp; 
    int error; 
    error=pthread_create(&tidp,null,create,null); 
    if(error!=0) 
 { 
    printf("pthread_create is not created ...."); 
    return -1; 
 } 
 printf("pthread_create is created ..."); 
 return 0; 
 }

解决方案 »

  1.   

    错误提示为:root@scofield-laptop:/home/scofield/myprogram# gcc ThreadShare.c -o ThreadShare
    ThreadShare.c: In function ‘main’:
    ThreadShare.c:15: error: ‘null’ undeclared (first use in this function)
    ThreadShare.c:15: error: (Each undeclared identifier is reported only once
    ThreadShare.c:15: error: for each function it appears in.)请大家多多指教啊~~
      

  2.   

    error=pthread_create(&tidp,NULL,create,NULL); 
    "null"改为"NULL".
    编译的时候需要加上-lptthread选项gcc -lpthread test.c
      

  3.   

    啊啊啊,,,
    ./(编译生成的目标)
    上面编译生成test,在终端里面运行./test
      

  4.   

    出现一下问题:bash: ./ThreadShare.c: 权限不够
    root@scofield-laptop:/home/scofield/myprogram# 怎么办?
      

  5.   

    网上查了一下又出现下面的问题:root@scofield-laptop:/home/scofield/myprogram# chmod 777 -R ThreadShare.c
    root@scofield-laptop:/home/scofield/myprogram# ./ThreadShare.c
    ./ThreadShare.c: line 5: static:找不到命令
    ./ThreadShare.c: line 6: 在未预料的“(”附近出现语法错误
    ./ThreadShare.c: line 6: `void *create(void *arg) '
    root@scofield-laptop:/home/scofield/myprogram# gcc -lpthread ThreadShare.c -o ThreadShare
    root@scofield-laptop:/home/scofield/myprogram# ./ThreadShare.c./ThreadShare.c: line 5: static:找不到命令
    ./ThreadShare.c: line 6: 在未预料的“(”附近出现语法错误
    ./ThreadShare.c: line 6: `void *create(void *arg) '
    root@scofield-laptop:/home/scofield/myprogram# 
      

  6.   

    ThreadShare.c是你的程序源文件吧?
    在终端运行:
    gcc -o ThreadShare -lpthread ThreadShare.c
    ./ThreadShare