Function call run-time error

Started by
1 comment, last by Tera_Dragon 18 years, 11 months ago
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.
____________________________________________________________Programmers Resource Central
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

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

I was passing the strings by value [dead]
I changed it to pass by reference and it works now. Thanks a lot for the help.
____________________________________________________________Programmers Resource Central

This topic is closed to new replies.

Advertisement