lua-users home
lua-l archive

Re: c side package creation

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


> luaL_register(L,"org.conman.math",reg_math);
> Never had a problem.
This no longer works is 5.2 because in 5.1 luaL_register called
(the undocumented and badly named) luaL_findtable which did that magic,
but 5.2 lacks luaL_findtable.
If you want to keep this way of registering your libraries is 5.2,
but don't want to use or require LUA_COMPAT_MODULE when build Lua,
you can copy luaL_findtable from the 5.2 source and use this version
of luaL_register:
void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l) {
 lua_pushglobaltable(L);
 luaL_findtable(L,-1,libname,0);
 luaL_setfuncs(L,l,0);
}

AltStyle によって変換されたページ (->オリジナル) /