Search code examples
c++cluaffiluajit

LuaJIT FFI cdef doesn't understand 'class'?


class Myuser * MyClient_GetMyUser(AUser aUser);

This is the error for trying to declare that function with ffi.cdef:

Error: dllImport.lua:861: declaration specifier expected near 'class' at line 20

How is this possible? How would I go about declaring 'class' if I must do so within cdef?


Solution

  • class is a C++ keyword. It doesn't exist in C. LuaJIT expects C code, not C++ code in the FFI block.

    As for how to work around this, it depends on what you're doing. Either you make that a C struct, or you find a different way to access it.