From 9eadef013e77e1622c7c527a1cdfa6dcc2e906dd Mon Sep 17 00:00:00 2001 From: Jiaye Wu Date: Wed, 12 Dec 2018 15:05:14 +0800 Subject: [PATCH] Fix UNICODE issue of dlerror Current implementation is conflicting. If UNICODE is defined, FormatMessage() will be FormatMessageW(), and variable win_errormsg with type char can not be passed to it, which should be changed to TCHAR instead. Since we don't use UNICODE here, we can use FormatMessageA() directly to avoid conversion error. ``` my_global.h(1092): error C2664: 'DWORD FormatMessageW(D WORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list *)' : cannot convert argument 5 from 'char [2048]' to 'LPWSTR' ``` --- include/my_global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index 816c9dd87c6..fd31de115c8 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1077,7 +1077,7 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */ static inline char *dlerror(void) { static char win_errormsg[2048]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0, win_errormsg, 2048, NULL); return win_errormsg; }