[Mono-devel-list] P/Invoke and DLLs
jonpryor at vt.edu
Tue Feb 8 20:30:17 EST 2005
On Tue, 2005-02-08 at 13:54 -0800, Frank Bergmann wrote:
> Under Win32 I had to make these callbacks _stdcall, otherwise the .NET
> application would terminate after calling the callback because some
> stack values could not be saved. So under non-Windows platforms this
> won't happen?
Correct. The calling convention of callback functions is supposed to be
the same as the platform's default calling convention. Since most of
Win32 is StdCall, that is the default, even though the default calling
convention for C code is Cdecl. Go figure.
Since the default calling convention for Unix is Cdecl, callback
functions should also be Cdecl.
The one exception to this is Mono on Windows. Mono expects Cdecl
functions when it should expect StdCall functions. I'm not sure when
this will be fixed.
More information about the Mono-devel-list