title: C++ gettid() was not declared in this scope
body: <p>A simple program is: 
  I would like to get the thread ID of both of the threads using this gettid function. I do not want to do the sysCall directly. I want to use this function.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/thread/thread.hpp&gt;
  #include &lt;boost/date_time/date.hpp&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  using namespace boost;
  using namespace std;
  
  boost::thread thread_obj;
  boost::thread thread_obj1;
  
  void func(void)
  {
      char x;
      cout &lt;&lt; "enter y to interrupt" &lt;&lt; endl;
      cin &gt;&gt; x;
       pid_t tid = gettid();
      cout &lt;&lt; "tid:" &lt;&lt; tid &lt;&lt; endl;
      if (x == 'y') {
          cout &lt;&lt; "x = 'y'" &lt;&lt; endl;    
          cout &lt;&lt; "thread interrupt" &lt;&lt; endl;
      }
  }
  
  void real_main() {
  
     cout &lt;&lt; "real main thread" &lt;&lt; endl;
      pid_t tid = gettid();
      cout &lt;&lt; "tid:" &lt;&lt; tid &lt;&lt; endl;
  
      boost::system_time const timeout = boost::get_system_time() + boost::posix_time::seconds(3);
      try {
          boost::this_thread::sleep(timeout);
      }
      catch (boost::thread_interrupted &amp;) {
          cout &lt;&lt; "thread interrupted" &lt;&lt; endl;
      }
  
  }
  
  int main()
  {
      thread_obj1 = boost::thread(&amp;func);
      thread_obj = boost::thread(&amp;real_main);
      thread_obj.join();
  }
  </code></pre>
  
  <p>It gives Error on compilation; The use of gettid() has been done according to the man page:</p>
  
  <pre><code>$g++ -std=c++11 -o Intrpt Interrupt.cpp -lboost_system -lboost_thread
  Interrupt.cpp: In function ‘void func()’:
  Interrupt.cpp:17:25: error: ‘gettid’ was not declared in this scope
        pid_t tid = gettid();
  </code></pre>