Search code examples
c++cluaffiluajit

Pointers and Reference issue in LuaJIT FFI


I have this function (written in C++ here):

GameSession *theSession = NULL;
...
...
startSesion(&theSession)

I have managed to get this running properly using the LuaJIT FFI here:

local session = ffi.new("GameSession*[1]", {})
myDLL.startSession(session))

However, I now need this function in LuaJIT (written in C++ here):

setTimeout(theSession, 3000);

How can this be achived in LuaJIT? Basically how can I declare theSession* from theSession** using the FFI?


Solution

  • As per FFI Tutorial, you dereference pointers like this:

    theSession[0];