[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Quick and compatible solution to avoid explicit linkage in C libs
- From: Daurnimator <quae@...>
- Date: Tue, 21 Jul 2015 20:38:42 +1000
On 21 July 2015 at 19:22, Alexander Kluev <firstname.lastname@example.org> 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.