AggrorJorn Posted March 21, 2013 Share Posted March 21, 2013 Having some issues with adding a physics hook to an entity. //.h void PlayerUpdate(Entity* entity); // .cpp void PlayerUpdate(Entity* entity) { //update player } bool App::Start() { //Somewhere in start function System::AddHook(Entity::UpdatePhysicsHook,PlayerUpdate); ERROR: IntelliSense: argument of type "void (App::*)(Leadwerks::Entity *entity)" is incompatible with parameter of type "void *" Quote Link to comment Share on other sites More sharing options...
tjheldna Posted March 21, 2013 Share Posted March 21, 2013 Hi Aggror, I have this working if the hook is added to the entity itself... I had no need to define it in .h void UpdateMyPhysicsHook(Entity* entity) { blah blah } entity->AddHook(Entity::UpdatePhysicsHook, UpdateMyPhysicsHook); 1 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 21, 2013 Author Share Posted March 21, 2013 Aha thats it! Thanks Tim. Quote Link to comment Share on other sites More sharing options...
MCP Posted April 1, 2013 Share Posted April 1, 2013 ERROR:IntelliSense: argument of type "void (App::*)(Leadwerks::Entity *entity)" is incompatible with parameter of type "void *" Your compiler is rightfully complaining that your function pointer isn't of the correct type ie "void *". The error lies within the declaration of System::AddHook() which has "void *" as the second parameter. AddHook should expect a function pointer of type void NOT a void pointer as they are in fact two completely different things and this should be classified as a typo bug. The correct declaration for System::AddHook() should have been this.... typdef void (*vFunc)(Leadwerks::Entity *); AddHook(int hookid, vFunc hook) { ... } As a temporary measure you call cast all your function pointers to void pointers but generally speaking this is considered dangerous in the C++ world and some compilers may not allow you even to do that. In a case were compilation has been successful you will often run into instability issues, memory address violations or other runtime errors... Avoid! See this discussion on the subject... http://stackoverflow...er-as-parameter Quote "If our brains were simple enough for us to understand them, we'd be so simple that we couldn't." - Ian Stewart 1995. Link to comment Share on other sites More sharing options...
Furbolg Posted April 2, 2013 Share Posted April 2, 2013 Good explanation, didnt know/realized that AddHook is the real problem. Of course using void* is a bad thing, because void* can be anything. But there are exceptions for example if you know what void* represents, then it shouldnt be a problem to cast it ( beginthread etc. ): Quote Link to comment Share on other sites More sharing options...
lukhns Posted April 10, 2013 Share Posted April 10, 2013 Will this bug be fixed? or has anyone found a stable solution? I thought maybe it would be fixed in the next build, but im still unable to compile on OSX using AddHook with a void pointer. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 13, 2013 Share Posted April 13, 2013 Cast the function pointer to a void* and it will work. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
xtreampb Posted April 22, 2013 Share Posted April 22, 2013 i tried this and it doesn't run on OS X. It compiles then crashes Quote bool Life() { while(death=false) { if(death==true) return death; } } I have found the secret to infinite life Did I help you out? Like my post! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.