Re: gettid

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

 



* Jonny Grant <jg@xxxxxxxx>, 2020-06-16, 12:36:
SYNOPSIS         top
  #define _GNU_SOURCE
  #include <unistd.h>
  #include <sys/types.h>

  pid_t gettid(void);

I can compile on Ubuntu without #define _GNU_SOURCE and call gettid()

Maybe that line can be removed?

I don't think so. Here's what I get (with GCC 9):

  $ gcc test.c
  test.c: In function ‘main’:
  test.c:6:9: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
      6 |  return gettid();
        |         ^~~~~~
        |         getgid

Prepending "#define _GNU_SOURCE" fixes the above.

--
Jakub Wilk
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char **argv)
{
	return gettid();	
}

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux