Skip to main content
gamedev.net
🔒 Locked

Function declaration order problem..

Started by AlphaDog 5 replies 1.5k views
Original Post
AlphaDog
AlphaDog
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.'
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
AlphaDog
AlphaDog
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.'
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
AlphaDog
AlphaDog
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.'
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.