title: Warning C4996: This function or variable may be unsafe -- compared to GCC on POSIX
body: <p>I notice that MS compilers give "deprecated" warnings for <code>cstdlib</code> functions like <code>getenv</code>. MS has invented its own standard such as <code>_dupenv_s</code>.</p>
  
  <h2>Question 1</h2>
  
  <p>AFAIK the main "unsafe" thing is about reentrancy *. Since MS's CRT is marked as "multi-threaded" (<code>/MT</code>), why don't they just replace <code>getenv</code> with the reentrant, thread-safe version? Is it like anybody would depend on the unsafe behavior?</p>
  
  <h2>Question 2</h2>
  
  <p>I compiled the same code with GCC <code>g++ -Wall -Wextra -Weff++ -pedantic foo.cpp</code> and it doesn't yield any warnings. So I guess this is not a problem on POSIX? How is this solved? (OK maybe they just changed the behavior of <code>getenv</code>, would be nice to have this confirmed).</p>
  
  <p>* <em>It's an over-generalization to say that its' only about reentrancy. Of course we have things like <code>strncpy_s</code> which changes the signature completely and deals with buffer size. But doesn't change the core of this question</em></p>