title: Do I need -D_REENTRANT with -pthreads?
body: <p>On Linux (kernel 2.6.5) our build system calls gcc with <code>-D_REENTRANT</code>.</p>
  
  <p><strong>Is this still required when using <code>pthreads</code>?</strong></p>
  
  <p>How is it related to <code>gcc -pthread</code> option? I understand that I should use <code>-pthread</code> with pthreads, do I still need <code>-D_REENTRANT</code>?</p>
  
  <p>On a side note, is there any difference that you know off between the usage of REENTRANT between gcc 3.3.3 and gcc 4.x.x ?</p>
  
  <p>When I use <code>-pthread</code> gcc option I can see that <code>_REENTRANT</code> gets defined. Will omitting <code>-D_REENTRANT</code> from command line make any difference, for example could some objects be compiled without multithreaded support and then linked into binary that uses pthreads and will cause problems?</p>
  
  <p><strong>I assume it should be ok just to use:</strong> <code>g++ -pthread</code></p>
  
  <pre><code>&gt; echo | g++          -E -dM -c - &gt; singlethreaded
  &gt; echo | g++ -pthread -E -dM -c - &gt; multithreaded
  &gt; diff singlethreaded multithreaded
  39a40
  &gt; #define _REENTRANT 1
  </code></pre>
  
  <p>We're compiling multiple static libraries and applications that link with the static libraries, both libraries and application use pthreads.</p>
  
  <p>I believe it was required at some stage in the past but want to know if it is still required. Googling hasn't returned any recent information mentioning -<code>D_REENTRANT</code> with <code>pthreads</code>. Could you point me to links or references discussing the use in recent version of <strong>kernel/gcc/pthread</strong>?</p>
  
  <p>Clarification: At the moment we're using -D_REENTRANT and -lpthread, I assume I can replace them with just g++ -pthread, looking at man gcc it sets the flags for both preprocessor and linker. Any thoughts?</p>