q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
181 stars 24 forks source link

Support passing string through `ffi.string()` #10

Closed vsergeev closed 4 years ago

vsergeev commented 4 years ago
local ffi = jit and require('ffi') or require('cffi')

local s = "hello world"
print(ffi.string(s)) --> expected: "hello world", get: bad argument #1 to 'string' (cannot convert 'string' to 'char const *')

LuaJIT FFI allows passing a string argument through ffi.string().