Re: calling convention stdcalll and cdecl call



"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2CC27965-06FB-4E77-B4A9-D73B1D8D1942@xxxxxxxxxxxxx
Both stdcall and cdecl calling convention could support variable input
parameters? Is that correct?

No. Variadic functions must use cdecl calling convention.

(I think stdcall is using RET N and cdecl is using ESP - N, so both
are capable to handle variable number of input parameter, like
printf?)

I have no idea what "RET N" or "ESP - N" is supposed to mean.

With stdcall, the function is responsible for removing its parameters
from the stack. To do this, it must know how many parameters there are,
and thus cannot take variable number of parameters.

With cdecl, the caller is responsible for removing parameters after the
called function returns. The caller of course knows how many parameters
it has just pushed on the stack, so there's no problem removing them.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.


Loading