lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have noticed that lua doesn't like when compiled with unicode in visual studio so i tracked down
the problem to loadlib.c and fixed it

line 101: DWORD n = GetModuleFileName(NULL, buff, nsize);

patched:
#ifdef UNICODE
 DWORD n = GetModuleFileNameA(NULL, buff, nsize);
#else
 DWORD n = GetModuleFileName(NULL, buff, nsize);
#endif


line 115-116:
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
     NULL, error, 0, buffer, sizeof(buffer), NULL))

patched:
#ifdef UNICODE
if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
     NULL, error, 0, buffer, sizeof(buffer), NULL))
#else
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
     NULL, error, 0, buffer, sizeof(buffer), NULL))
#endif

line 128:
 HINSTANCE lib = LoadLibrary(path);

patched:
#ifdef UNICODE
 HINSTANCE lib = LoadLibraryA(path);
#else
 HINSTANCE lib = LoadLibrary(path);
#endif

The line numbers are from lua version 5.1.1. Basicly I use normal ascii version of the api function when using unicode mode. I also ifdeffed the normal' version if there is no unicode define because if someone is using old
version of win api (win 95?).