lua-users home
lua-l archive

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

That works, thanks a lot John.

On May 8, 2021, at 5:05 PM, Jonathan Goble <> wrote:

On Sat, May 8, 2021 at 4:46 PM Varanda <> wrote:
Hello All,

In my bindings I have a library created in C (using luaL_newlib)

Later on, In some situation, I would like to have another C code appending more functions into that existing library.

How can I do this only using C?

The resulting library is just an ordinary table containing functions, and luaL_newlib leaves that table on the top of the stack. Store a reference to that in the registry using luaL_ref and LUA_REGISTRYINDEX, then later you can fetch that table and use luaL_setfuncs again (luaL_newlib uses that function under the hood), or do it one at a time with the standard table manipulation functions.