This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dll question


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]