Support passing pointer for array argument
Closed this issue · 0 comments
vsergeev commented
local ffi = jit and require('ffi') or require('cffi')
ffi.cdef[[
int pipe(int fildes[2]);
]]
--[[
-- also:
local buf = ffi.new('int [2]')
local pipe_fds = ffi.cast('int *', buf)
]]--
local pipe_fds = ffi.new('int [2]')
ffi.C.pipe(pipe_fds) --> expected: no error, get: cannot convert 'int *' to 'int [2]'
print(pipe_fds[0]) --> 3
print(pipe_fds[1]) --> 4
It appears that cdata<T [N]>
and cdata<T *>
types cannot be passed as an argument to a function expecting T [N]
.