delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/11/23:22:20

From: smueller AT microsoft DOT com (Stephan Mueller)
Subject: RE: __stdcall functions in relocatable DLLs
11 Jan 1998 23:22:20 -0800 :
Message-ID: <60602D8F29B3D011879800805FD4722401749FE6.cygnus.gnu-win32@red-11-msg.dns.microsoft.com>
To: "'Joao Pedro Sousa'" <js AT servisoft DOT pt>,
Jason Alan Nordwick
<nordwick AT graft DOT XCF DOT Berkeley DOT EDU>
Cc: gnu-win32 AT cygnus DOT com

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 AT 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 AT servisoft DOT pt]
> Sent:	Sunday, January 11, 1998 12:58 PM
> To:	Jason Alan Nordwick
> Cc:	gnu-win32 AT cygnus DOT 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 AT cygnus DOT com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019