[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Quick and compatible solution to avoid explicit linkage in C libs
- From: Alexander Kluev <akluev@...>
- Date: Tue, 21 Jul 2015 12:22:11 +0300
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