Advertisement

MessageCallback with asCALL_THISCALL

Started by November 16, 2008 01:21 PM
3 comments, last by B_old 16 years ago
Hi again, my stuff runs again now after the update, except that this seems to be a problem (only in debug, running fine in release):

m_engine->SetMessageCallback(asMETHOD(ScriptEngine, messageCallback), this, asCALL_THISCALL);
This is the error message I get: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. Any ideas? Thanks.
Is your messageCallback a static method of the ScriptEngine? If it is then you need to register it with asCALL_CDECL instead of asCALL_THISCALL. If that is not the problem, then please show us the ScriptEngine::messageCallback function signature so that we can verify if it is correct (parameters, return type, etc).

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
It is a non-static method:
//.hclass ScriptEngine {//...        asIScriptEngine *m_engine;public://...	void messageCallback(const asSMessageInfo *msg, void *param);};//.cpp//...m_engine->SetMessageCallback(asMETHOD(ScriptEngine, messageCallback), this, asCALL_THISCALL);

Works fine in release but not in debug.
When the message callback is implemented as a class method it shouldn't have a second parameter. Only the asSMessageInfo pointer. This is why you get the stack corruption.

See: http://www.angelcode.com/angelscript/sdk/docs/manual/classas_i_script_engine.html#74192fe950808eb72a64e3e371f0ea02

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thank You!

This topic is closed to new replies.

Advertisement