Skip to content

Commit

Permalink
Explicit sign conversions on Windows (#255)
Browse files Browse the repository at this point in the history
Add explicit casts to support compiling with -Wsign-conversion on Windows.
  • Loading branch information
DanilChapovalov authored May 24, 2023
1 parent 5ea9047 commit ee24973
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/time_zone_lookup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ std::string win32_local_time_zone(const HMODULE combase) {
UINT32 wlen;
const PCWSTR tz_wstr = windows_get_string_raw_buffer(tz_hstr, &wlen);
if (tz_wstr) {
const int size = WideCharToMultiByte(CP_UTF8, 0, tz_wstr, wlen, nullptr,
0, nullptr, nullptr);
result.resize(size);
WideCharToMultiByte(CP_UTF8, 0, tz_wstr, wlen, &result[0], size,
nullptr, nullptr);
const int size =
WideCharToMultiByte(CP_UTF8, 0, tz_wstr, static_cast<int>(wlen),
nullptr, 0, nullptr, nullptr);
result.resize(static_cast<size_t>(size));
WideCharToMultiByte(CP_UTF8, 0, tz_wstr, static_cast<int>(wlen),
&result[0], size, nullptr, nullptr);
}
windows_delete_string(tz_hstr);
}
Expand Down

0 comments on commit ee24973

Please sign in to comment.