lua-users home
lua-l archive

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


On 14 January 2017 at 17:19, Sean Conner <sean@conman.org> wrote:
>   The major issue I have with LuaJIT's ffi is that you can't feed it C
> header files.  I mean, if they're relatively clean (sans #defines and #if
> stuff) you could probably get away with it, but otherwise, you have to
> declare all structures and prototypes.  Ideally, you do something like:
>
>         ffi.define { MAXSEG_64K = 1 } -- we need this defined for this example
>         ffi.include("zlib.h")
>
> and now you can use zlib. But I do admit that such an interface is a *major*
> undertaking and I can understand why no one has done it yet.

What I find to be the major issue is that you cannot 'namespace' defines.
i.e. there can only be one 'struct foo' or 'typedef bar qux' per lua state.

This means that libraries that want to use the ffi are setting *global* state.
It also brings up questions+issues about where common dependency
declarations should live.

When the ffi first came out (>5 years ago!) I I tried to solve it with
https://github.com/daurnimator/lua-ffi-util
But in the end I sort of felt the ffi was dead end/distraction.

I now don't bother with the ffi and only write lua C modules.