This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: dll question
- To: gnu-win32 at cygnus dot com
- Subject: Re: dll question
- From: Benjamin Riefenstahl <benny at crocodial dot de>
- Date: Thu, 28 May 1998 13:58:04 +0200
- Organization: Crocodial Communications EntwicklungsGmbH
- References: <m0yepeD-00117KC@malasada.lava.net>
Hi Tim,
Tim Newsham wrote:
> After the call, the stack pointer seems to be off by 12 bytes (too high).
> Its as if the called procedure popped the arguments itself, leaving
> the stack as it was prior to the caller pushing, and then the caller
> also added 12 to the stack pointer to pop the values, after the function
> returned.
>
> Is this analysis correct?
Yes.
> If not, what is actually going on here?
Microsoft calls it the __stdcall calling convention. It's used for the
Windows API and recommended (for compatibility if for no other reason)
for all DLL interfaces.
> If
> so, is there some way to tell the compiler that the callee will be
> restoring the stack and that the caller shouldn't bother?
You specify the calling convention in the declaration of the function
pointer type. E.g.
typedef int __stdcall function_with_3_arguments_type( int, int, int );
function_with_3_arguments_type * function_with_3_arguments_ptr = NULL;
I'm doing the declaration in two steps here for portability and
readability.
If you want to document that you are using the __stdcall calling
convention for compatibility with Windows, you can #include<windows.h>
and spell it WINAPI instead of __stdcall.
so long, benny
======================================
Benjamin Riefenstahl (benny@crocodial.de)
Crocodial Communications EntwicklungsGmbH
Ruhrstraße 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".