Page 1 of 1

Strange Function Error

Posted: Wed Jun 17, 2009 9:28 am
by rangana
Hi Guys,

I am using wxWidgets for my application. I get this random crash (Please see the Attached image) in the application both in debug and release versions.

Any ideas please for this behaviour?

Posted: Wed Jun 17, 2009 10:00 am
by Muetdhiver
This message speaks by itself. But can you isolate the code that makes the app crash please and post it here ?

Difficult to see without this.
Bye

Posted: Wed Jun 17, 2009 11:17 am
by TrV
Maybe some unmanaged exception ?

Posted: Wed Jun 17, 2009 12:24 pm
by Muetdhiver
No.
In fact, I already had this error but I don't remember when and why !!
Maybe it was due to function pointers that were not used as they should do.
For instance, you declare 2 function pointers with two different prototypes, and you want to use one of these two functions but with the pointer that is not the correct one.

That why I want to see the code, maybe I could guess something with it !! :)

Bye !

Posted: Thu Jun 18, 2009 9:49 am
by Frank
As Muetdhiver said, the error is slef explaining.

Your calling a function with another calling convention then the function is compiled.

Eg. an OPTLINK function with SYSTEM linkage. The calling convention tells the compiler how to remove the parameters from the stack. eg. the function cleans up, like in pascal, or the callsite does it like in c(++). OPTLINK (Or _or fastcall for Visual Studio), uses registers for the parameters where possible, wich is of course much faster than the stack.

It's a compiler switch. In Visual Studio you find it under C++/Advanced. Default ist _cdecl. So when wx is compiled with _cdecl and you project ist compiled with fastcall you crash.

Also it can be a part of the function declaration, if one want to overwrite the default. eg.

int __stdcall myFunc (whatever);

But because those are normally in the header, wich is the same for the function and the caller, your problem lies probable in the project settings.

Worked

Posted: Thu Jun 18, 2009 11:24 am
by rangana
Thanks Muetdhiver for the advice!

I just went through my method code and found some unusual pointer references. I coded in normal way and error is no more.

Thanks