I've got a very small program to test thread related stuff:
#include<unistd.h>
#include<sys/types.h>
#include<stdio.h>
int main()
{
pid_t pid=getpid();
pid_t tid=gettid();
printf("%d,%d\n",pid,tid);
return 0;
}
Within vim editor, I focus on 'gettid' and Shift-K, the man page of gettid says it's inside sys/types. No problem, when I compile it, there's error:
g++ mythread.cpp
mythread.cpp: In function ‘int main()’:
mythread.cpp:7:22: error: ‘gettid’ was not declared in this scope
pid_t tid=gettid();
^
I'm on ubuntu1604 with new gcc version. How to fix it?