Subject: Re: dll question
From: [email-masked] (Benjamin Riefenstahl)

29 May 1998 02:38:49 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
To: [email-masked]

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 ([email-masked])
Crocodial Communications EntwicklungsGmbH
Ruhrstraße 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".