lua-users home
lua-l archive

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


I'll reply to both, Geoff Leyland and Roberto Ierusalimschy in this post:


On 10/26/11 04:09, Geoff Leyland wrote:
...
> Sorry for not being clearer. The issue is that a quick test suggests that patch as presented breaks builds on mingw/XP.
...

Yes, that's a mess, The patch also breaks "Win32" compilation!

In my Visual Studio 2008 installation most functions like LoadLibrary, LoadLibraryEx, GetDiskFreeSpace
exist with an 'A' and a 'W' ending, and a macro construct like:

#ifdef UNICODE
#define GetDiskFreeSpace  GetDiskFreeSpaceW
#else
#define GetDiskFreeSpace  GetDiskFreeSpaceA
#endif // !UNICODE

decides, which of the two is used.

This is however not the case with GetProcAddress() for Win32 programs.

On WinCE both versions exist, UNICODE is always defined and therefore GetProcAddress is defined as GetProcAddressW which fails to compile in loadlib.c, since it expects a wchar_t * parameter for the
lpProcName.

Redefining GetProcAddress in luaconf.h is not possible, since loadlib.c includes <windows.h> after including
lua.conf and so redefines it back to GetProcAddressW.

On 10/26/11 14:13, Roberto Ierusalimschy wrote:
...
... We never apply patches: coding is easy, we can do
that. So, a brief description of the changes should be enough on the
"how" side.  What we are interested are the reasons for the patch, the
"why" side of the story.


I hope the above explication explains the "why" - side. I was trying (successfully) to compile the lua
sources under a Windows CE/Windows Mobile SDK.

The attached patches are very short, and should help to explain what I want to achieve:

lua51_wince.patch:

loadlib.c: The already mentioned GetProcAddress() problem. in the ll_sym() function.

luaconf.h: first chunk of the patch file: "#if defined(_WIN32_WCE)"

- some Win32 functions are not available in Windows CE, I declare them in a separate wince.h file

- in print.c, VOID is defined in conflict with the definition in WinNT.h. It seems hoewever, that by reordering of lines this problem has gone away and #undef VOID is not anymore needed in my
  setup

- in lundump.c the function LoadString() is defined, which also exists in the Windows API.

luaconf.h: second chunk of the patch file: "#ifndef _WIN32_WCE"

- in WinCE all libraries and executables included in the "Operating System Image" are found in the \Windows directory.
  therefore I added this path to LUA_PATH_DEFAULT.
This has some importance, since WinCE has no environment variables which could be set to "correct" the search path. However - library loading is another open point which seems not to work on WinCE without further investigation

luaconf.h: third chunk of the patch file: "+#elif defined(_MSC_VER)"

- this is the LUAI_FUNC ... issue:
my setup is to build the lua.exe and luac.exe only from lua.c, luac.c and print.c and link them dynamically to
  lua51.dll, which contains all other files.

  When linking luac.obj, I get:

luac.obj : error LNK2019: unresolved external symbol luaU_dump referenced in function pmain luac.obj : error LNK2019: unresolved external symbol luaM_toobig referenced in function combine luac.obj : error LNK2019: unresolved external symbol luaM_realloc_ referenced in function combine luac.obj : error LNK2019: unresolved external symbol luaS_newlstr referenced in function combine luac.obj : error LNK2019: unresolved external symbol luaD_growstack referenced in function combine luac.obj : error LNK2019: unresolved external symbol luaF_newproto referenced in function combine
  print.obj : error LNK2001: unresolved external symbol luaP_opmodes
  print.obj : error LNK2001: unresolved external symbol luaP_opnames

the easy way was to export the respective symbols. It has been suggested to link luac statically to the respective files. This I wanted to avoid, to reduce size of the overall installation on the WinCE embedded device.

luaconf.h: fourth and fifth chunk of the patch file:

- If LUA_WIN is defined it is assumed, that _isatty(), popen() and pclose() are available. This is not the case on WinCE so I added "&& !defined(_WIN32_WCE)" to the respective preprocessor clauses.

- - -

lua52_wince.patch

liolib.c:  popen()/pclose() issue has migrated from luaconf.h to this file
loadlib.c: GetProcAddress() issue
lua.c:     _isatty() issue has migrated from luaconf.h to this file
luaconf.h: remaining issues.

- - -

Best Regards,

    Jorge-León

On 10/25/11 22:37, Georg Lehner wrote:
Hello!

I would like to contribute a patch to the original lua sources, which facilitate compilation under Microsoft compilers. lua51_wince.patch applies to a clean lua-5.1.4\src directory and
lua52_wince.patch to a clean lua-5.2.0-beta\src directory.

In some Windows API function calls just an "A" was appended to the name to force the use of
the ANSI version instead of the UNICODE version of the function.

luaconf.h adds support for Windows Mobile/Windows CE compilers (_WIN32_WCE) by excluding some
features (like popen).

LUAI_FUNC and LUAI_DATA/LUAI_DDEC are declared for proper export with _delcspec(dllexport) under _MSC_VER just like already done for LUA_API and LUALIB_API. I needed this for luac.exe.

The LoadString() function in lundump.c conflicts with the WindowsAPI LoadString() function.
The patches handle this situation only under _WIN32_WCE.

- - -

Is this the usual way to get changes eventually into the lua sources?

Best Regards,

    Jorge-León