Re: Is CALLBACK or WINAPI is necessary?
- From: "William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx>
- Date: Tue, 26 Apr 2005 13:11:26 -0400
"Tom Alter" <Lord2702@xxxxxxx> wrote in message
news:e96wp7hSFHA.688@xxxxxxxxxxxxxxxxxxxxxxx
> Suppose when I am creating my own library, then I will
> not use CALLBACK or WINAPI, but then if caller has the
> problem for not able to use the functions from the library,
> then can caller override this modifiers in his own application?
No.
> Because till this time no one is saying that it is necessary or not.
Well, early on I pointed out that caller and callee _must_ agree on a
caliing convention. On x86 chips and under Win32, what the convention boils
down to (it is a little more in truth) a question as to who pops the
arguments off the stack.
C and C++ programs built with the MS compiler, in the absence of compiler
options to the contrary, operate in a mode in which the both caller pushes
the arguments onto the stack and pops them off the stack onm return.
This allows for variable length argument lists (a practice more common in C
than C++) for a given function. Functions marked STDCALL, CALLBACK, WINAPI,
__stdcall etc move the responsibility for normalizing the strack to the
callee.
Now, since on x86 chips, the return address of a function is on the stack as
well, if caller and callee don't agree on convention chances are that the
function will be called sucessfully but on return wind up in no-man's land.
Regards,
Will
.
- Follow-Ups:
- Re: Is CALLBACK or WINAPI is necessary?
- From: Tom Alter
- Re: Is CALLBACK or WINAPI is necessary?
- References:
- Is CALLBACK or WINAPI is necessary?
- From: Tom Alter
- Re: Is CALLBACK or WINAPI is necessary?
- From: Tom Alter
- Is CALLBACK or WINAPI is necessary?
- Prev by Date: Re: How much oop is too much oop?
- Next by Date: Re: Get Flash memory serial number?
- Previous by thread: Re: Is CALLBACK or WINAPI is necessary?
- Next by thread: Re: Is CALLBACK or WINAPI is necessary?
- Index(es):
Relevant Pages
|