[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

undefined reference to `gettid'



Hello,

  Reading doc from 'man gettid', I wrote the following program:

$ cat gettid.c
#include <sys/types.h>
#include <linux/unistd.h>
#include <errno.h>

int main()
{
  _syscall0(pid_t, gettid); /* need to add a trailing ; */
  pid_t d = gettid();
  return 0;
}


Apparently my compiler (gcc) does not like the _syscall0:

$ gcc gettid.c
gettid.c:5: error: expected declaration specifiers or '...' before 'gettid'
gettid.c:5: warning: data definition has no type or storage class

I had to comment out the function call, but then I am getting:

$ gcc gettid.c
/tmp/ccal5UtC.o: In function `main':
gettid.c:(.text+0xe): undefined reference to `gettid'
collect2: ld returned 1 exit status

Should I simply assumed that gettid should not be used and instead
replaced it with pthread_self as this should be the default on all
linux/debian system ?

Thanks,
-- 
Mathieu


Reply to: