🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Crash when calling RegisterGlobalFunction()

Started by
2 comments, last by WitchLord 18 years, 4 months ago
I'm adding AngelScript support to my game and when I call
scriptEngine->RegisterGlobalFunction("void printOutput(string &str)", asFUNCTION(printOutput), asCALL_CDECL)
my app crashes My printOutput looks like this:
void printOutput(std::string &str)
{
	MyEngine::Instance().console->print(str.c_str());
}
The crash is caused when the RegisterGlobalFunction somehow calls my function from RegisterGlobalFunction(), the value for str passed to printOutput is an invalid pointer. How can I fix this? Thanks
Advertisement
Are you saying that RegisterGlobalFunction() is calling the function you're registering? That shouldn't be possible, try debugging the library to see what's going on.

If it is really the script that is calling your function, and passing an invalid string reference then you'll want to take a look at how the string type was registered.

Perhaps if you could show us a little bit more about how you're configuring the engine, then we might be able to help you better.

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

Sorry, my mistake, the problem wasn't RegisterGlobalFunction but the function I used with SetCommonMessageStream. Now fixed it, sorry I made you waste time answering.
No problem :)

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

This topic is closed to new replies.

Advertisement