On 17/06/2020 11:22, Jakub Wilk wrote: > * 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. Hi Jakub, Apologies, I should have shared my test case, I was compiling as C++ // g++ -Wall -o tid tid.cpp #include <unistd.h> #include <sys/types.h> int main() { return gettid(); } $ g++ -Wall -o tid tid.cpp tid.cpp:3: warning: "_GNU_SOURCE" redefined 3 | #define _GNU_SOURCE | <command-line>: note: this is the location of the previous definition Looks like it is set by default, even when specifying the C++ standard version for g++ g++ -std=c++11 -Wall -o tid tid.cpp Checked, yes, if compiling as C, see the same result as you. Not sure how it gets enabled by default in my c++ $ g++ --version g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0 Cheers, Jonny