2012-12-23 32 views

Trả lời

9
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

Aha! Bạn phải sử dụng '[1]' thay vì '*' thứ hai! Làm cho tinh thần, nhưng có một số nhận được sử dụng để. –

Các vấn đề liên quan