FFI callbacks with structs as arguments.

  • From: Zach Devito <zdevito@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 23 Jan 2013 18:50:08 -0800

I have a Lua function that I want to use as a callback from C. The C type
of the callback includes a struct as argument.
When I try to create this callback in LuaJIT, I get an error. For instance:

ffi = require("ffi")
ffi.cdef("typedef struct {} A;")
ffi.cdef("typedef (*fn)(A);")
function myfn(a)
result = ffi.cast("fn",myfn) -- cannot convert 'function' to 'void (*)()'

Is this functionality not currently supported?



Other related posts: