jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S.open in ljsyscall

jmckaskill opened this issue · comments

lua: unable to convert argument 2 from cdata to cdata<int64_t>

lua: unable to convert argument 2 from cdata<int> to cdata<int64_t>
stack traceback:
   [C]: in function 'open'
    ./io/syscall.lua:2388: in function 'open'

Minimal test case (I wrote ljsyscall, happy to get it to work with luaffi)

local ffi = require "ffi"

local C = ffi.C

ffi.cdef[[
typedef uint32_t mode_t;
int open(const char *pathname, int flags, mode_t mode);
]]

local int_t = ffi.typeof("int")

assert(ffi.C.open("/tmp/file/does/not/exist", int_t(1), 0))

note I fixed this issue in ljsyscall, although it seems to be a bug. Working on other issues.

Ah I see what's happening. I was wondering how he had managed to create a cdata because any access to an int is normally converted to a lua number.