lua-users home
lua-l archive

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


On 19.04.22 13:06, Hugo Musso Gualandi wrote:
> A) Package and install the pallenelib via Luarocks and tell Pallene modules to
> require() this library. One challenge is that the library needs to export C
> symbols, not just Lua functions.

One solution could be to export the C functions of the module using Lua
mechanisms, e.g. attaching a userdata object to the required module containing a
struct of function pointers. This gives maximum flexibility, e.g. it also works
if there are several Lua main states in the process (even different versions).
One disadvantage may be that invoking these functions must always be done
through a function pointer.

You may also have a look at my approach on https://github.com/lua-capis to
obtain Lua module interoperation at the native C side.

/Oliver