Recent

Author Topic: Access violation calling stdcall external C DLL  (Read 23065 times)

lero

  • New member
  • *
  • Posts: 7
Re: Access violation calling stdcall external C DLL
« Reply #15 on: March 20, 2011, 12:07:42 am »
@marcov
You are right. The project is all in stdcall. The Calling Convention in C compiler is defined as __stdcall, but I didn't notice that this group of functions I'm calling are in cdecl. I've searched for the declaration and found this code:

Code: [Select]
#ifdef API_DLL
 #define api __declspec(dllexport)

And in the header I've found
Code: [Select]
int api c_function(c_typedef *var1, c_typedef *var2)
As C is not my native langague and I was not aware of this specific difference in the functions convention of the project, adding the fact that in Delphi all the code was working fine, lead me to wrongly conclude there was a problem with the Free Pascal compilation.
Solution: Simple changing the declaration of the functions from stdcall to cdecl and I've got no more SIGSEGV errors!!!

Thank you guys!

 

TinyPortal © 2005-2018