[Mono-list] Mono/.NET delegate incompatibility

Jonathan Pryor jonpryor@vt.edu
19 Dec 2002 07:43:55 -0500


`__stdcall' (the keyword) was just added for GCC 3.4, or "stdcall" stack
ordering was just added?

It can't be the latter.  I know I've used "stdcall" functions from GCC
since (at least!) 2.95, probably earlier.  It's needed to call any Win32
API function.

Granted, it was `__attribute__((stdcall))', not `__stdcall', so that
might be the difference.

Either way, if you need to compile a function using the `stdcall'
calling convention under GCC, this should work:

#ifndef STDCALL
#define STDCALL __attribute__((stdcall))
#endif

void (STDCALL *func)(int);

- Jon

On Wed, 2002-12-18 at 22:18, Fergus Henderson wrote:
> On 18-Dec-2002, Miguel de Icaza <miguel@ximian.com> wrote:
> > Hello,
> > 
> > > I am using a delegate to pass a function pointer into a unmanaged DLL.
> > > Under Linux/Mono everything works fine. Under Windows/.NET, my callback
> > > function signature must look like this:
> > > 
> > >   void (__stdcall *func)(int);
> > > 
> > > But Windows/Mono seems to want:
> > > 
> > >   void (*func)(int);
> > 
> > __stdcall is a Microsoft-C feature, so it is really a feature of your
> > compiler.
> 
> It's also a feature also of the Windows ABI.
> 
> Note that support for __stdcall has just recently been added to GCC
> (the main CVS branch -- it should be included in GCC 3.4, I think).