Skip to content

Build at Windows throws warning at comparism  #1986

@matgrundler

Description

@matgrundler

I Am building a project on multiple platforms (Ubuntu 22.04, Windows 11).
With the latest changes of httplib (0.18.1) i will get the following warning when compiling under Windows 11 with mingw64/g++-Compiler (GCC 12):

./include/httplib.h: In function 'std::wstring httplib::detail::u8string_to_wstring(const char*)': ./include/httplib.hpp:2275:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<wchar_t>::size_type' {aka 'long long unsigned int'} [-Wsign-compare] 2275 | if (wlen != ws.size()) { ws.clear(); } | ~~~~~^~~~~~~~~~~~

If i change the line:

auto wlen = ::MultiByteToWideChar(CP_UTF8, 0, s, len, nullptr, 0);

to the following code:

auto wlen = static_cast<long long unsigned int>(::MultiByteToWideChar(CP_UTF8, 0, s, len, nullptr, 0));

this is fixed by explicit cast to the same Type of the later used "ws.size()"-Value

and there are no more warnings from httplib.h.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions