From 1f23a7838000e6fd5f7a1ae6bb85791ce7c08ad7 Mon Sep 17 00:00:00 2001 From: Luigi 'Comio' Mantellini Date: Mon, 24 Mar 2014 13:44:04 +0100 Subject: [PATCH] Remove some warning. --- Foundation/src/NumericString.cpp | 15 +++++++++------ Foundation/src/utils.h | 7 ++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Foundation/src/NumericString.cpp b/Foundation/src/NumericString.cpp index 37ecf7f..e5dc939 100644 --- a/Foundation/src/NumericString.cpp +++ b/Foundation/src/NumericString.cpp @@ -63,6 +63,9 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec poco_assert_dbg (precision > 0); poco_assert_dbg (str.length()); + std::string::size_type _precision = static_cast(precision); + std::string::size_type _width = static_cast(width); + std::string::size_type decSepPos = str.find(decSep); if (decSepPos == std::string::npos) { @@ -81,17 +84,17 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec str = str.substr(0, str.length() - eStr->length()); } - if (frac != precision) + if (frac != _precision) { - if (frac < precision) - str.append(precision - frac, '0'); - else if ((frac > precision) && (decSepPos != std::string::npos)) - str = str.substr(0, decSepPos + 1 + precision); + if (frac < _precision) + str.append(_precision - frac, '0'); + else if ((frac > _precision) && (decSepPos != std::string::npos)) + str = str.substr(0, decSepPos + 1 + _precision); } if (eStr.get()) str += *eStr; - if (width && (str.length() < width)) str.insert(str.begin(), width - str.length(), prefix); + if (_width && (str.length() < _width)) str.insert(str.begin(), _width - str.length(), prefix); } diff --git a/Foundation/src/utils.h b/Foundation/src/utils.h index 767094b..6465e84 100644 --- a/Foundation/src/utils.h +++ b/Foundation/src/utils.h @@ -35,6 +35,11 @@ #ifndef ASSERT #define ASSERT(condition) (assert(condition)) #endif +#if __cplusplus >= 201103L +#define STATIC_ASSERT(b, str) static_assert(b, str) +#else +#define STATIC_ASSERT(b, str) typedef char __StaticAssertCheck[b ? 1 : -1] +#endif #ifndef UNIMPLEMENTED #define UNIMPLEMENTED() (abort()) #endif @@ -296,8 +301,7 @@ template inline Dest BitCast(const Source& source) { // Compile time assertion: sizeof(Dest) == sizeof(Source) // A compile error here means your Dest and Source have different sizes. - DOUBLE_CONVERSION_UNUSED - typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1]; + STATIC_ASSERT(sizeof(Dest) == sizeof(Source), "Dest and Source must have the same size"); Dest dest; memmove(&dest, &source, sizeof(dest));