Say I have this C function:
__declspec(dllexport) const char* GetStr()
{
static char buff[32]
// Fill the buffer with some string here
return buff;
}
And this simple Lua module:
local mymodule = {}
local ffi = require("ffi")
ffi.cdef[[
const char* GetStr();
]]
function mymodule.get_str()
return ffi.C.GetStr()
end
return mymodule
How can I get the returned string from the C function as a Lua string here:
local mymodule = require "mymodule"
print(mymodule.get_str())