Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Multiple inheretence method problems

Started by Wavesonics May 27, 2009 at 3:11 PM 1 replies 2.5k views
Original Post
Wavesonics
Wavesonics
I think I may have brought this up a long time ago, but I finally have a reproducible case in my code. I can try and create a minimal case for it later, but here is the general idea: When I call a inherited method from a parent class in a multiple inheritance hierarchy, I get undefended behavior (either a crash or non-sense return values):

class GameObject;

class Creep : public GameObject;

class Drawable {
    int someFunc();
}

class CreepClient : public Creep, public Drawable;

// ==========================================================================
// Then I register CreepClient with AS, and some of the methods of Drawable:
// ==========================================================================
    r = engine->RegisterObjectMethod("CreepClient", "int someFunc()", asMETHOD(CreepClient, someFunc), asCALL_THISCALL); assert( r >= 0 );


Then in my script I have something like:

void scriptFunc( CreepClient@ c ) {
    int i = c.someFunc();
    print( i ); // This prints non-sense
}


But really it's any method called from the Drawable base class. I found how ever, that if I use the "asMETHODPR" macro instead, it all works :)
WitchLord
WitchLord
This is with GCC 4.x, right?

I have to install GCC again and give this a try so I can investigate it.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.