From c6d6cada99a1d6e0cf494a26612484e429539ccd Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Sat, 9 Aug 2008 15:35:12 +0000 Subject: [PATCH] GCC 4.3 fixes, thanks to Tom Browder git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@898 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/CachedFactory.h | 2 +- include/loki/LevelMutex.h | 3 +++ include/loki/SafeFormat.h | 15 ++++----------- test/OrderedStatic/main.cpp | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/loki/CachedFactory.h b/include/loki/CachedFactory.h index e87f424..391f5bf 100644 --- a/include/loki/CachedFactory.h +++ b/include/loki/CachedFactory.h @@ -516,7 +516,7 @@ namespace Loki { if(m_vKeys.empty()) throw EvictionException(); - size_type random = static_cast((m_vKeys.size()*rand())/int(RAND_MAX + 1)); + size_type random = static_cast((m_vKeys.size()*rand())/(static_cast(RAND_MAX) + 1)); remove(*(m_vKeys.begin()+random)); } const char* name(){return "random";} diff --git a/include/loki/LevelMutex.h b/include/loki/LevelMutex.h index 43cf336..c048000 100644 --- a/include/loki/LevelMutex.h +++ b/include/loki/LevelMutex.h @@ -34,6 +34,9 @@ #include #endif +#if !defined(_WIN32) && !defined(_WIN64) + #include // declares sleep under Linux +#endif /** @par thread_local Keyword The mutexes require compilers to provide thread local storage - meaning each diff --git a/include/loki/SafeFormat.h b/include/loki/SafeFormat.h index 93e1db5..d49c0c5 100644 --- a/include/loki/SafeFormat.h +++ b/include/loki/SafeFormat.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -207,7 +207,7 @@ namespace Loki result_ = -1; return *this; } - const size_t len = std::min(strlen(s), prec_); + const size_t len = std::min(std::strlen(s), prec_); if (width_ > len) { if (LeftJustify()) { Write(s, s + len); @@ -397,15 +397,8 @@ namespace Loki const Char hex1st = uppercase ? 'A' : 'a'; for (;;) { const LOKI_SAFEFORMAT_UNSIGNED_LONG next = n / base; -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4244) -#endif - Char c = n - next * base; -#ifdef _MSC_VER -#pragma warning(pop) -#endif - c += (c <= 9) ? '0' : hex1st - 10; + Char c = static_cast(n - next * base); + c += (c <= static_cast(9)) ? '0' : static_cast(hex1st - 10); *bufLast = c; n = next; if (n == 0) break; diff --git a/test/OrderedStatic/main.cpp b/test/OrderedStatic/main.cpp index 66d5734..cb13201 100644 --- a/test/OrderedStatic/main.cpp +++ b/test/OrderedStatic/main.cpp @@ -74,7 +74,7 @@ Loki::OrderedStatic<1,L1> l1; Loki::OrderedStatic<2,L2> l2; Loki::OrderedStatic<1, std::string, std::string(*)() > s1( &func ); -Loki::OrderedStatic<2, std::string, Loki::Seq > s2( "s2" ); +Loki::OrderedStatic<2, std::string, Loki::Seq > s2( "s2" ); Loki::OrderedStatic<1, Loki::Functor, Loki::Seq > f1(f);