lua-users home
lua-l archive

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




On 21/07/15 07:38 AM, Daurnimator wrote:
On 21 July 2015 at 19:22, Alexander Kluev <akluev@inbox.ru> wrote:
Another quick and backward compatible solution to avoid explicit linkage in
C libs is passing path to lua*.dll as a second arg to luaopen_*

So it will be posible avoid static linkage and use dynamic linking to
current lua*dll instead.
Old method will also work.

for example

void luaopen2_mylib(lua_State *L, const wchar_t *lua_dll) // new luaopen2_
signature for two args function
{
     HMODULE h = LoadLibraryW(lua_dll); // load actual lua.dll

// obtain api
     dll_pushnumber = GetProcAddress(h, "lua_pushnumber");
     dll_pushcclosure = GetProcAddress(h, "lua_pushcclosure");
     // ...

// use api
     dll_pushnumber(L, 3.14);
}

for statick linkage just use old luaopen_ signature


I was thinking of a slight variation this morning.
Declare your entry point as with a version suffix: luaopen53_mylib.
Then the built-in search can be modified to add the current version to
the symbol it looks for.

There are benefits to having a single C function signature
(e.g., package.loadlib) that I'd prefer to keep.

dlmopen()

Not that I know how to use it...

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.