Skip to content

Commit

Permalink
Fix UNICODE issue of dlerror()
Browse files Browse the repository at this point in the history
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'
```
  • Loading branch information
Jiaye Wu authored and vaintroub committed Dec 11, 2018
1 parent 1b31d88 commit 8dc460b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/my_global.h
Expand Up @@ -1068,7 +1068,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;
}
Expand Down

0 comments on commit 8dc460b

Please sign in to comment.