lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,
I am testing LuaJIT FFI binding and i have a problem with this code :

****
local ffi = require("ffi")
ffi.cdef[[
struct slice{
  char *data;
  int len;
};
]]
local sk = ffi.new("struct slice")
sk.len = 3
sk.data = "">
print(sk.len)
print(ffi.string(sk.data))
****
The last line cause LuaJIT to crash and the "sk.data = "" assignement complain with this message : cannot convert 'string' to 'char *'

I know that i am doing something wrong and i would apreciate very much some help.

Thanks in advance.

Olivier.