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.
Thanks. I am on it ;)
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;
}
Declaring it as a string pointer will allow you to pass null, maybe that's why I was wanting the dereferencing to work.
but it is a pointer. Isnt it?
Lewis
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.
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
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.
no its not a pointer to MYSQL, just returns a MYSQL structure.
Lewis
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
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.
yes its a static library. Ive checked the headers and MYSQL is just a structure.
Lewis
And the original function definition?
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
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.
Nevermind, we found it. The nm tool is used to list symbols in case anyone's interested.