IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Mike Stefanik on January 13, 2006, 03:39:21 AM

Title: Access violation in acparse.exe
Post by: Mike Stefanik on January 13, 2006, 03:39:21 AM
This (incorrect) code will cause acparse.exe to throw an access violation and die instead of reporting the error:


global sub NullBug(),string
{
return null;
}

global sub main()
{
writeln("Ouch!\n");
}


It looks like the parser doesn't like "null" being passed as a return value there.
Title: Re: Access violation in acparse.exe
Post by: Ionic Wind Support Team on January 13, 2006, 07:18:05 AM
Thanks.  I am on it ;)
Title: Re: Access violation in acparse.exe
Post by: Zen on January 13, 2006, 09:32:53 AM
Ive just had a crash too. Here's the code...


declare extern mysql_init(MYSQL *MySQL),MYSQL;

MySQL :: MySQL() {

initialized = false;

object = mysql_init(null); /* Removing This Line Stops The Crash */

// if(object <> null) {

// initialized = true;

// }

return;

}
Title: Re: Access violation in acparse.exe
Post by: Parker on January 13, 2006, 03:20:33 PM
Declaring it as a string pointer will allow you to pass null, maybe that's why I was wanting the dereferencing to work.
Title: Re: Access violation in acparse.exe
Post by: Zen on January 13, 2006, 03:32:51 PM
but it is a pointer. Isnt it?

Lewis
Title: Re: Access violation in acparse.exe
Post by: Parker on January 13, 2006, 04:15:51 PM
I mean on the line that says mysql_init. You should declare it as
declare import/extern(??) mysql_init(string *param),return_type;
of course that won't compile since you have to know the return_type and whether it uses import or extern.
Title: Re: Access violation in acparse.exe
Post by: Zen on January 13, 2006, 04:30:50 PM
look at the code i posted above i have got this...

declare extern mysql_init(MYSQL *MySQL),MYSQL;


Is that not what you mean?

Lewis
Title: Re: Access violation in acparse.exe
Post by: Parker on January 13, 2006, 04:34:29 PM
Oh oops, I didn't see that :-[

What is object declared as? If it's a MYSQL* then make the function return POINTER, since typed pointer returns are not supported, and not needed.
Title: Re: Access violation in acparse.exe
Post by: Zen on January 13, 2006, 04:41:51 PM
no its not a pointer to MYSQL, just returns a MYSQL structure.

Lewis
Title: Re: Access violation in acparse.exe
Post by: Zen on January 14, 2006, 06:52:25 AM
Ok. I sorted my problem. it was because i had created an empty structure. I just made it until i had the externals done for the MySQL library. Even still it is crashing the parser rather than returning an error.

Lewis
Title: Re: Access violation in acparse.exe
Post by: Ionic Wind Support Team on January 14, 2006, 08:11:19 AM
I think what parker is saying is Aurora can return structures from functions as it uses heap memory to do so, most other languages can't, including C. 

declare extern mysql_init(MYSQL *MySQL),MYSQL;

Would be wrong since Aurora is expecting the function to return a MYSQL structure from the external function, unless of course mysql_init is your own.  If your using a third party DLL then it should also be an "import" not an "extern".

If it is a third party library check the header carefully for #typdef's to see what MYSQL resolves to.

Paul.
Title: Re: Access violation in acparse.exe
Post by: Zen on January 14, 2006, 08:13:44 AM
yes its a static library. Ive checked the headers and MYSQL is just a structure.

Lewis
Title: Re: Access violation in acparse.exe
Post by: Ionic Wind Support Team on January 14, 2006, 08:26:20 AM
And the original function definition?
Title: Re: Access violation in acparse.exe
Post by: Zen on January 14, 2006, 08:41:08 AM
From the MySQL Manual it says...

MYSQL *mysql_init(MYSQL *mysql)


So i guess it actualy returns a pointer to that structure. I am having linking to the static library function at compile time also. Its say unresolved extern but i have the library in the libs directory and am using the #use statement.

Any ideas on that one?

Lewis
Title: Re: Access violation in acparse.exe
Post by: Parker on January 14, 2006, 10:05:53 AM
I would say
declare cdecl extern mysql_init(MYSQL* mysql),pointer;

Anyone know what the argument I can use with ar to get the globals of a library? This one is giving us lots of problems.
Title: Re: Access violation in acparse.exe
Post by: Parker on January 14, 2006, 10:21:55 AM
Nevermind, we found it. The nm tool is used to list symbols in case anyone's interested.