- 论坛徽章:
- 0
|
代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
void *handler(void *arg)
{
printf("tid = %x pid = %d \n",gettid(),getpid());
return NULL;
}
int main()
{
pthread_t tid;
int ret = pthread_create(&tid,NULL,handler,NULL);
if(ret)
{
fprintf(stderr,"%s\n",strerror(ret));
exit(1);
}
printf("tid = %x pid = %d \n", gettid(), getpid());
pthread_join(tid,NULL);
pthread_exit(NULL);
}
错误提示:
/tmp/cc4qHlVx.o: In function `handler':
gettid.c .text+0xf): undefined reference to `gettid'
/tmp/cc4qHlVx.o: In function `main':
gettid.c .text+0xa7): undefined reference to `gettid'
collect2: ld returned 1 exit status |
|