From a9862fdb220da8ab0a4d7b3aa179216eaacb16a0 Mon Sep 17 00:00:00 2001 From: jdale88 Date: Tue, 11 Mar 2014 18:56:24 +0000 Subject: [PATCH 1/2] Fixed some level 4 warnings in VS2013 --- format.cc | 17 +++++++++++++---- format.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/format.cc b/format.cc index 8bb7c6bf..c3170cd0 100644 --- a/format.cc +++ b/format.cc @@ -39,6 +39,11 @@ using fmt::ULongLong; +#if _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + namespace { #ifndef _MSC_VER @@ -237,7 +242,7 @@ void fmt::BasicWriter::FormatDouble( char sign = 0; // Use SignBit instead of value < 0 because the latter is always // false for NaN. - if (SignBit(value)) { + if (SignBit(static_cast(value))) { sign = '-'; value = -value; } else if (spec.sign_flag()) { @@ -259,7 +264,7 @@ void fmt::BasicWriter::FormatDouble( return; } - if (IsInf(value)) { + if (IsInf(static_cast(value))) { // Format infinity ourselves because sprintf's output is not consistent // across platforms. std::size_t size = 4; @@ -628,7 +633,7 @@ void fmt::BasicFormatter::DoFormat() { } else { out = writer.GrowBuffer(1); } - *out = arg.int_value; + *out = static_cast(arg.int_value); break; } case STRING: { @@ -667,7 +672,7 @@ void fmt::BasicFormatter::DoFormat() { void fmt::ColorWriter::operator()(const fmt::BasicWriter &w) const { char escape[] = "\x1b[30m"; - escape[3] = '0' + color_; + escape[3] = '0' + static_cast(color_); std::fputs(escape, stdout); std::fwrite(w.data(), 1, w.size(), stdout); std::fputs(RESET_COLOR, stdout); @@ -731,3 +736,7 @@ template void fmt::BasicFormatter::CheckSign( const wchar_t *&s, const Arg &arg); template void fmt::BasicFormatter::DoFormat(); + +#if _MSC_VER +# pragma warning(pop) +#endif diff --git a/format.h b/format.h index fd35afea..18c9567b 100644 --- a/format.h +++ b/format.h @@ -81,7 +81,7 @@ #if _MSC_VER # pragma warning(push) -# pragma warning(disable: 4521) +# pragma warning(disable: 4521) // 'class' : multiple copy constructors specified #endif namespace fmt { From 4cabe16241454cbc554059a9904bf185dd0603f6 Mon Sep 17 00:00:00 2001 From: jdale88 Date: Tue, 11 Mar 2014 19:03:26 +0000 Subject: [PATCH 2/2] Should use Char not char, as Char is typedef'd to the correct type (char or wchar_t) --- format.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format.cc b/format.cc index c3170cd0..090e3f4d 100644 --- a/format.cc +++ b/format.cc @@ -633,7 +633,7 @@ void fmt::BasicFormatter::DoFormat() { } else { out = writer.GrowBuffer(1); } - *out = static_cast(arg.int_value); + *out = static_cast(arg.int_value); break; } case STRING: {