[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: warning using luaL_newlib
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 12 Jan 2017 09:41:52 -0200
> 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