在 2024-10-21 21:26, Antonin Décimo 写道:
+ mod = GetModuleHandleA("kernelbase.dll");
+ if (mod)
+ {
+ _pthread_set_thread_description =
+ (HRESULT (WINAPI *)(HANDLE, PCWSTR)) GetProcAddress(mod,
"SetThreadDescription");
As discussed earlier, this cast causes a warning about conversion between incompatible function pointers. An intermediate cast through `(void*)` is necessary.
+ if (_pthread_set_thread_description != NULL)
+ {
+ size_t required_size = mbstowcs(NULL, name, 0);
+ if (required_size != (size_t)-1)
+ {
+ wchar_t *wname = malloc((required_size + 1) * sizeof(wchar_t));
+ if (wname != NULL)
+ {
+ mbstowcs(wname, name, required_size);
The 3rd argument should be `required_size + 1`. Microsoft documentation is lying; this is actually the maximum number of `wchar_t` that will be written, so it must include the null terminator.
Pushed with two fixes of these issues. -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
