Compare commits

...

2 Commits

Author SHA1 Message Date
c6f47a0981 CMakeLists.txt: improve searching for hidapi
All checks were successful
Alpine 3.21 Success
Debian-based distributions don't include the CMake module.
2025-08-02 18:55:44 +02:00
c8f3b9ba38 eizoctl: fix compatibility with newer MinGW-w64
All checks were successful
Alpine 3.21 Success
2025-08-02 17:47:40 +02:00
2 changed files with 14 additions and 8 deletions

View File

@@ -41,13 +41,16 @@ pkg_check_modules (libusb libusb-1.0)
# On MSYS2, the CMake package cannot link statically, but pkg-config can.
# On macOS, we explicitly want to use the CMake package.
if (WIN32)
pkg_search_module (hidapi hidapi hidapi-hidraw hidapi-libusb)
else ()
find_package (hidapi)
if (NOT WIN32)
find_package (hidapi QUIET)
if (hidapi_FOUND)
set (hidapi_INCLUDE_DIRS)
set (hidapi_LIBRARY_DIRS)
set (hidapi_LIBRARIES hidapi::hidapi)
endif ()
endif ()
if (NOT hidapi_FOUND)
pkg_search_module (hidapi hidapi hidapi-hidraw hidapi-libusb)
endif ()
option (WITH_LIBUSB "Compile with libusb-based utilities" ${libusb_FOUND})

View File

@@ -1251,10 +1251,13 @@ message_printf(const char *format, va_list ap)
return NULL;
mbstowcs(format_wide, format, format_wide_len);
int message_len = vswprintf(NULL, 0, format_wide, ap) + 1;
// Note that just vswprintf() cannot be used like this
// (at least since mingw-w64 commit c85d64),
// and vsnwprintf() is a MinGW extension, acting like C11 vsnwprintf_s.
int message_len = vsnwprintf(NULL, 0, format_wide, ap) + 1;
wchar_t *message = calloc(message_len, sizeof *message);
if (message_len > 0 && message)
vswprintf(message, message_len, format_wide, ap);
vsnwprintf(message, message_len, format_wide, ap);
free(format_wide);
return message;