delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/29/02:38:49

From: benny AT crocodial DOT de (Benjamin Riefenstahl)
Subject: Re: dll question
29 May 1998 02:38:49 -0700 :
Message-ID: <356D514C.EA79A959.cygnus.gnu-win32@crocodial.de>
References: <m0yepeD-00117KC AT malasada DOT lava DOT net>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

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 AT crocodial DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


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