🎉 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!

Function declaration order problem..

Started by
5 comments, last by WitchLord 18 years, 7 months ago
I'm guessing I have something configured incorrectly. I have setup a system that automatically loads scripts and calls Main(). I'm having strange behavior when calling functions in main() defined outside of main. If I have the following script:

void test( string @ s )
{
   string t = s;
}
void Main()
{
   test( "this is a test" );
}
I get an 'Null pointer access' error for the line 'string t = s', but if I set up the script this way:

void Main()
{
   test( "this is a test" );
}
void test( string @ s )
{
   string t = s;
}
Everything runs perfectly.. Is this by design? or have I setup something incorrectly. Thanks, Scott
[size=1]'Behold! It is not over unknown seas but back over well-known years that your quest must go; back to the bright strange things of infancy and the quick sun-drenched glimpses of magic that old scenes brought to wide young eyes.'
Advertisement
By design it should not make a difference in what order the functions are implemented.

I need to look into this. I'll be back with more information as soon as possible.

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 just tested both of these scripts using version 2.4.1b with the asCScriptString add on and everything worked fine, without any null-pointer access exceptions.

How did you register the string type? Maybe there is some error with the constructor and/or addref/release behaviours. Or possibly the assignment behaviour.

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 knew it was something I was doing.. :)

I am using the asCScriptString included with the SDK and I am calling RegisterScriptString(), passing it my engine pointer created with asCreateScriptEngine. Looks like I'm going to have to dig a bit deeper into my code to see where I am going wrong. Thanks for looking at it.. I'll keep you updated..

~Scott

[Edited by - AlphaDog on November 17, 2005 2:01:07 PM]
[size=1]'Behold! It is not over unknown seas but back over well-known years that your quest must go; back to the bright strange things of infancy and the quick sun-drenched glimpses of magic that old scenes brought to wide young eyes.'
Can you reproduce the problem in a small test application (similar to the test_feature) that you can send to me?

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

It was my fault all along, it had to do with how I was managing the function ID for Main(). It is working perfectly now, thanks again for the help and keep up the great work.

~Scott
[size=1]'Behold! It is not over unknown seas but back over well-known years that your quest must go; back to the bright strange things of infancy and the quick sun-drenched glimpses of magic that old scenes brought to wide young eyes.'
Ahh, that's one less to worry about. Thanks for letting me know. [smile]

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