__stdcall functions in relocatable DLLs

Stephan Mueller smueller@microsoft.com
Sun Jan 11 20:11:00 GMT 1998


Note also that functions declared with __stdcall have an underscore prefixed
and an at sign followed by argument byte count suffxed, in the DLL.  So
	int func(int a, double b)
in your source becomes
	_func@12
in the DLL.

For varargs functions, the caller must clear the stack, since the callee
can't know how many bytes to pop.  In these cases, __stdcall becomes
standard C calling convention (__cdecl in some compilers.)

In general, functions exported from a DLL can be __cdecl.

There are numerous other calling conventions, but many of them are obsolete.
Amongst the many that are or were at one time available on Windows platforms
through Microsoft compilers:
	__pascal	(args left to right, callee cleans stack)
	__fortran	(synonym for __pascal)
	__syscall	(definitely obsolete)
	__fastcall	(first few args passed in registers)
	__thiscall	(C++; 'this' passed in ECX)

stephan(not speaking for, just working for, my employer);

> -----Original Message-----
> From:	Joao Pedro Sousa [SMTP:js@servisoft.pt]
> Sent:	Sunday, January 11, 1998 12:58 PM
> To:	Jason Alan Nordwick
> Cc:	gnu-win32@cygnus.com
> Subject:	Re: __stdcall functions in relocatable DLLs
> 
> At 09:48 11-01-1998 -0800, Jason Alan Nordwick wrote:
> >
> >Is there anywhere or anything that explains the different calling
> >conventions ?
> 
> __stdcall is the Win32 function calling convention. It specifies that
> function parammeters are pushed on the stack from right to left, and the
> called function cleans up the stack on function exit. On some
> architectures
> (e.g. i386) this can be slightly faster by using a special instruction
> that
> returns from the function and removes a specified number of bytes from the
> stack (ret n).
> The "normal" C calling convention places the burden of cleaning the stack
> on the caller side.
> 
> By the way, anyone knows if exported functions on a DLL MUST be __stdcall?
> Can they be C calling convention?
> 
> --
> JPSousa
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list