diff --git a/include/loki/SafeFormat.h b/include/loki/SafeFormat.h index 950557d..56089f4 100755 --- a/include/loki/SafeFormat.h +++ b/include/loki/SafeFormat.h @@ -347,12 +347,19 @@ namespace Loki } memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char)); fmtBuf[format_ - fmt] = 0; + + const int stored = #ifdef _MSC_VER - const int stored = _snprintf_s(resultBuf, +#if _MSC_VER < 1400 + _snprintf #else - const int stored = snprintf(resultBuf, + _snprintf_s +#endif +#else + snprintf #endif - sizeof(resultBuf) / sizeof(Char), fmtBuf, n); + (resultBuf, sizeof(resultBuf) / sizeof(Char), fmtBuf, n); + if (stored < 0) { result_ = -1; return; diff --git a/test/SafeFormat/main.cpp b/test/SafeFormat/main.cpp index e7f3d91..36bf5d5 100755 --- a/test/SafeFormat/main.cpp +++ b/test/SafeFormat/main.cpp @@ -17,8 +17,13 @@ #include "../SmallObj/timer.h" #if defined(_MSC_VER) -#define sprintf sprintf_s +#if _MSC_VER >= 1400 +#define sprintf sprintf_s #define _snprintf _snprintf_s +else +#define sprintf sprintf +#define _snprintf _snprintf +#endif #endif using namespace std;