Lua with C++ classes!! Teh noes!!
Okay, I have a function like this:
int TileMap::Load_Map_Lua ( lua_State *L )
And I register it like this:
lua_register ( lua_state, "load_map", Load_Map_Lua );
It's correctly defined, right? It returns int, passes in the lua_State... But when I try to register it, they tell me, that the it's not correctly defined for to be exported to Lua!!
I get this error:
error C2664: 'lua_pushcclosure' : cannot convert parameter 2 from 'int (lua_State *)' to 'lua_CFunction'
Is it because of the fact I'm passing a function that belongs to a class? What can I do about it?
Help!! ;__;
Quote:Original post by riyunoa
Okay, I have a function like this:
int TileMap::Load_Map_Lua ( lua_State *L )
And I register it like this:
lua_register ( lua_state, "load_map", Load_Map_Lua );
Is it because of the fact I'm passing a function that belongs to a class? What can I do about it?
Yep.
A pointer-to-member-function is not a pointer to a function.
You will need to pass either a pointer to a namespace-level function or a pointer to a static member function to the callback. You will probably need to pass a pointer to an object of your class to your callback, somehow.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement