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]