开通VIP,畅享免费电子书等14项超值服
首页
好书
留言交流
下载APP
联系客服
2014.01.12
Assuming there is following C code:
struct Foo { int dummy; }int tryToAllocateFoo(Foo ** dest);
...How to do following in LuaJIT?
Foo * pFoo = NULL;tryToAllocateFoo(&pFoo);
local ffi = require 'ffi'ffi.cdef [[ struct Foo { int dummy; }; int tryToAllocateFoo(Foo ** dest);]]local theDll = ffi.load(dllName)local pFoo = ffi.new 'struct Foo *[1]'local ok = theDll.tryToAllocateFoo(pFoo)if ok == 0 then -- Assuming it returns 0 on success print('dummy ==', pFoo[0].dummy)end
[1]
*
微信登录中...请勿关闭此页面