MS VS2015 compilation fix. It’s better to use native Win32 (strncpy_s, sprintf_s) to avoid compilation errors when building by MS C++.

This commit is contained in:
Philip 2016-10-21 18:22:24 +03:00
parent 4e39b23e45
commit 366e7c7e4b
2 changed files with 11 additions and 2 deletions

View File

@ -1377,7 +1377,12 @@ namespace crow
case type::Number:
{
char outbuf[128];
#ifdef _MSC_VER
sprintf_s(outbuf, 128, "%g", v.d);
#else
sprintf(outbuf, "%g", v.d);
#endif
out += outbuf;
}
break;

View File

@ -222,8 +222,12 @@ inline char * qs_scanvalue(const char * key, const char * qs, char * val, size_t
{
qs++;
i = strcspn(qs, "&=#");
strncpy(val, qs, (val_len-1)<(i+1) ? (val_len-1) : (i+1));
qs_decode(val);
#ifdef _MSC_VER
strncpy_s(val, val_len, qs, (val_len - 1)<(i + 1) ? (val_len - 1) : (i + 1));
#else
strncpy(val, qs, (val_len - 1)<(i + 1) ? (val_len - 1) : (i + 1));
#endif
qs_decode(val);
}
else
{