Advertisement Jump to content
Sign in to follow this  

References and uninstanciable objects

This topic is 3823 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

I've registered an object like this:
Engine->RegisterObjectType( "Helper", 0, asOBJ_REF );
Engine->RegisterObjectBehaviour("Helper", asBEHAVE_ADDREF, "void f()", asMETHOD(CHelper, AddRef), asCALL_THISCALL);
Engine->RegisterObjectBehaviour("Helper", asBEHAVE_RELEASE, "void f()", asMETHOD(CHelper, Release), asCALL_THISCALL);

// CHelper *GetHelper()
Engine->RegisterGlobalFunction( "Helper @GetHelper()", asFUNCTION( GetHelper ), asCALL_CDECL )

When I write a script like this:
int main()
    Helper m = GetHelper();

The build function fails with -1, but I don't get any compiler warnings. I then realized that I needed to make the variable a reference, but I wonder why the compiler doesn't tell me (I have set a message callback, but it isn't called). Did I do a mistake somewhere or is this a bug? Okay, I solved it, I used cdecl as the calling convention for a member method: changed it to thiscall, now the callback function does work. [Edited by - SiS-Shadowman on August 3, 2008 2:48:50 PM]

Share this post

Link to post
Share on other sites
I do now, no need to look at it :)
I placed the wrong calling convention in the messagecallback registration, wich resulted in my callback never being called.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!