Jump to content
  • Advertisement
Sign in to follow this  
riyunoa

Lua with C++ classes!! Teh noes!!

This topic is 4674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!! ;__;

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!