I notice that MS compilers give "deprecated" warnings for cstdlib
functions like getenv
. MS has invented its own standard such as _dupenv_s
.
Question 1
AFAIK the main "unsafe" thing is about reentrancy *. Since MS's CRT is marked as "multi-threaded" (/MT
), why don't they just replace getenv
with the reentrant, thread-safe version? Is it like anybody would depend on the unsafe behavior?
Question 2
I compiled the same code with GCC g++ -Wall -Wextra -Weff++ -pedantic foo.cpp
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 getenv
, would be nice to have this confirmed).
* It's an over-generalization to say that its' only about reentrancy. Of course we have things like strncpy_s
which changes the signature completely and deals with buffer size. But doesn't change the core of this question