Sign in to follow this  

MessageCallback with asCALL_THISCALL

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

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
It is a non-static method:

//.h
class 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 3315 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this