From 6fd70aff22dedfc0a3e710aaba49d3921d4976e8 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Fri, 26 Jul 2024 20:21:07 +0200 Subject: [PATCH] bytes_to_str(): fix MSVC `'>': signed/unsigned mismatch` warning MSVC doesn't display this warning even with `/W4`, one has to provide `/Wall`. But I guess some people are seeing this, see https://github.com/roelschroeven/kaitai_struct_cpp_stl_runtime/commit/179318868e7a9185ac06f9cc8d28a57fb9e1a08a For the record, here's what the entire warning looked like: ``` C:\temp\kaitai_struct\runtime\cpp_stl\kaitai\kaitaistream.cpp(893,22): warning C4388: '>': signed/unsigned mismatch [C:\temp\kaitai_struct\runtime\cpp_stl\build\kaitai_struct_cpp_stl_runtime.vcxproj] ``` --- kaitai/kaitaistream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kaitai/kaitaistream.cpp b/kaitai/kaitaistream.cpp index dc2749e..9332ae5 100644 --- a/kaitai/kaitaistream.cpp +++ b/kaitai/kaitaistream.cpp @@ -890,7 +890,7 @@ std::string kaitai::kstream::bytes_to_str(const std::string src, int codepage) { std::wstring utf16; int32_t utf16_len; int32_t src_len; - if (src.length() > std::numeric_limits::max()) { + if (src.length() > static_cast(std::numeric_limits::max())) { throw bytes_to_str_error("buffers longer than int32_t are unsupported"); } else { src_len = static_cast(src.length());