remove last msvc warnings

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@448 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-01-07 10:31:24 +00:00
parent e06a92ea87
commit f09bf76ce3
2 changed files with 13 additions and 8 deletions

View file

@ -204,7 +204,7 @@ namespace Loki
// read the result // read the result
operator int() const { operator int() const {
return result_; return static_cast<int>(result_);
} }
private: private:
@ -341,7 +341,7 @@ namespace Loki
memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char)); memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char));
fmtBuf[format_ - fmt] = 0; fmtBuf[format_ - fmt] = 0;
#ifdef _MSC_VER #ifdef _MSC_VER
const int stored = _snprintf(resultBuf, const int stored = _snprintf_s(resultBuf,
#else #else
const int stored = snprintf(resultBuf, const int stored = snprintf(resultBuf,
#endif #endif

View file

@ -16,6 +16,11 @@
#include "../SmallObj/timer.h" #include "../SmallObj/timer.h"
#if defined(_MSC_VER)
#define sprintf sprintf_s
#define _snprintf _snprintf_s
#endif
using namespace std; using namespace std;
using namespace Loki; using namespace Loki;
@ -31,7 +36,7 @@ Integral2 RandomInt(Integral1 low, Integral2 up)
assert(n > 0); assert(n > 0);
const unsigned int bucket_size = RAND_MAX / n; const size_t bucket_size = RAND_MAX / n;
assert(bucket_size > 0); assert(bucket_size > 0);
Integral2 r; Integral2 r;
@ -39,7 +44,7 @@ Integral2 RandomInt(Integral1 low, Integral2 up)
r = Integral2(rand() / bucket_size); r = Integral2(rand() / bucket_size);
while (r > n); while (r > n);
r += low2; r = r + low2;
assert(r >= low2 && r <= up); assert(r >= low2 && r <= up);
return r; return r;
} }
@ -147,8 +152,8 @@ int main(int argc, char** argv)
string formatSpec(lead + "|%"); string formatSpec(lead + "|%");
// Generate a random set of flags // Generate a random set of flags
static const string flags("-+0 #"); static const string flags("-+0 #");
unsigned int maxFlags = RandomInt(0u, flags.length() - 1); size_t maxFlags = RandomInt(0u, flags.length() - 1);
for (unsigned int i = 0; i != maxFlags; ++i) for (size_t i = 0; i != maxFlags; ++i)
{ {
formatSpec += flags[RandomInt(0u, flags.length() - 1)]; formatSpec += flags[RandomInt(0u, flags.length() - 1)];
} }
@ -175,12 +180,12 @@ int main(int argc, char** argv)
static const string type("cdeEfgGinopsuxX");*/ static const string type("cdeEfgGinopsuxX");*/
static const string type("cdeEfgGinosuxX"); static const string type("cdeEfgGinosuxX");
const char typeSpec = type[RandomInt(0, type.size() - 1)]; const char typeSpec = type[RandomInt(0u, type.size() - 1)];
// Generate an optional type prefix // Generate an optional type prefix
static const string prefix("hl"); static const string prefix("hl");
if (typeSpec != 's' && RandomInt(0, 1)) if (typeSpec != 's' && RandomInt(0, 1))
{ {
formatSpec += prefix[RandomInt(0, prefix.size() - 1)]; formatSpec += prefix[RandomInt(0u, prefix.size() - 1)];
} }
formatSpec += typeSpec; formatSpec += typeSpec;
formatSpec += '|'; formatSpec += '|';