lua-users home
lua-l archive

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


> int register_class(lua_State *L, const char *name, const luaL_Reg *
> methods, const luaL_Reg *functions) {
> …
> …
>  luaL_newlib(L, functions);
> }

The manual says this about luaL_newlib:

  | The array l must be the actual array, not a pointer to it.

(It uses sizeof to compute the array size.) So, your use is incorrect.
You have to break it into more primitive calls:

-  luaL_newlib(L, functions);
+  lua_newtable(L);
+  luaL_setfuncs(L, functions, 0);

-- Roberto