Jump to content
  • Advertisement
Sign in to follow this  

Function call run-time error

This topic is 4774 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 have two functions: GUIElement *GetActiveElement(); GUIElement *FindElement(string); Both are registered with AngelScript. GetActiveElement() works, but FindElement does not. Windows gives me this error:
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 convention.
Could it be the string that is causing the error? I have included the scriptstring from the sample, and called RegisterScriptString(). If you need to know any more please just tell me.

Share this post


Link to post
Share on other sites
Advertisement
Does FindElement() expect a std::string by value? This would explain why ESP is wrong, since the library is pushing a asCScriptString on the stack, but FindElement() only removes a std::string.

Actually you cannot pass ScriptString to a function by value since it will not correctly handle the reference counting if that is so (the destructor is even protected to prevent C++ from instantiating the class locally). In fact, I may have to change the library to check for this case, as it is a configuration error.

Instead you ought to pass the string by reference, and register FindElement() with the following declaration "GUIElement@ FindElement(string &in)".

If this isn't the error, then you might want to verify the calling convention you specified when registering the function: asCALL_CDECL or asCALL_STDCALL.

Regards,
Andreas

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!