When built with MSVC and unicode enabled, using 'message' gave:
warning C4133: 'initializing': incompatible types - from 'TCHAR *' to 'char *'
FormatMessage expands to either FormatMessageA or FormatMessageW
depending if unicode is enabled, and generates either a char (8-bit)
or WCHAR (UTF-16) string accordingly.
Since sp_last_error_message() returns char *, we must use the 8-bit
variant. The message will be encoded in the current code page.
TRACE_VOID();
#ifdef _WIN32
- TCHAR *message;
+ char *message;
DWORD error = GetLastError();
- DWORD length = FormatMessage(
+ DWORD length = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &message,
+ (LPSTR) &message,
0, NULL );
if (length >= 2 && message[length - 2] == '\r')