diff --git a/std/cstdlib.hpp b/std/cstdlib.hpp index e119843d52..8268726dcf 100644 --- a/std/cstdlib.hpp +++ b/std/cstdlib.hpp @@ -1,11 +1,26 @@ #pragma once +#include "target_os.hpp" + #ifdef new #undef new #endif #include +// setenv is absent in MSVC. +#ifdef OMIM_OS_WINDOWS_NATIVE +#include // Need it for snprintf. +inline int setenv(char const * name, char const * value, int /*overwrite*/) +{ + char buffer[255]; + int const err = ::snprintf(buffer, sizeof(buffer), "%s=%s", name, value); + if (err < 0 || err >= sizeof(buffer)) + return -1; + return ::_putenv(buffer); +} +#endif + #ifdef DEBUG_NEW #define new DEBUG_NEW #endif