C++: Why is there std::getenv but no std::setenv?

183 Views Asked by At

The C++ standard has std::getenv, but I have to fallback to C's setenv (and be hit with deprecation warnings for including <stdlib.h>).

Is there a reason for this?

1

There are 1 best solutions below

4
KamilCuk On

Is there a reason for this?

setenv() is operating system specific POSIX function. It's not part of the C programming language standard, so it's not imported in C++ in std:: namespace.