Re: calling convention

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Lisa Pearlson wrote:
I understand difference between __cdecl and __stdcall is who does cleanup,
the caller or callee.. correct?

Yes. Other differences might be the order in which function arguments are
pushed onto the stack. In general, it describes the protocol with which the
caller and callee communicate, be it via the stack or registers.

If you do not explicitly specify the calling convention, the default seems
to be __cdecl, yet all windows dll's use __stdcall. So is the latter only
interesting for DLLs?

No.

Can one type call another type? e.g.:

BOOL __cdecl MyCdeclFn()
{
return TRUE;
}
BOOL __stdcall MyStdFn()
{
return MyCdeclFn();
}

I guess not.. I get an error when I try this.

Which error? I don't get any.

And which calling convention is used when you LoadLibrary a DLL and then
use GetProc ? I've always done this with windows dll's as well as my own,
without consideration of calling convention..

You can also use GetProcAddress() to retrieve the address of an object.
Calling a function requires that you use the right calling convention, but
there is nothing that will help you with that, you must manually achieve
consistency.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
.



Relevant Pages

  • Re: write statement output buffer flush off on Sun
    ... > no tests or other conditional activities in either the caller or the ... > callee that need to be done in any order or that need to rely on ... > any form of branch prediction, speculative execution, or anything ... > up the stack properly and returns to the caller directly at the ...
    (comp.lang.fortran)
  • Re: [OT] [Question]activities of stack pointer and frame pointer when function called
    ... >>I suspect you don't understand what as stack frame is. ... A function stack frame is a method to keep track of function ... At the point of creation the caller is ... When the callee returns to its ...
    (comp.lang.c)
  • Re: what is a stack
    ... > the instruction pointer to what it used to be in the caller. ... > I forget who pops the parameters, the caller or the callee. ... it's normally up to the callee to reset the stack to the ...
    (comp.lang.java.programmer)
  • Re: what is a stack
    ... it pops its locals off the stack and restores ... >> the instruction pointer to what it used to be in the caller. ... >> I forget who pops the parameters, the caller or the callee. ...
    (comp.lang.java.programmer)
  • Re: Getting Information on a Calling Class
    ... on which class is calling the current class. ... public void callMe(Caller caller) ... Callee callee = new Callee; ...
    (comp.lang.java.programmer)