forked from organicmaps/organicmaps
setenv support for MSVC.
This commit is contained in:
parent
00dd0708ad
commit
6f7399ceee
1 changed files with 15 additions and 0 deletions
|
@ -1,11 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "target_os.hpp"
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
// setenv is absent in MSVC.
|
||||
#ifdef OMIM_OS_WINDOWS_NATIVE
|
||||
#include <cstdio> // 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
|
||||
|
|
Loading…
Add table
Reference in a new issue