Victor Bazarov wrote:
Larry I Smith wrote: Victor Bazarov wrote:
Larry I Smith wrote:
[...] For one thing the args to function calls are
pushed on to the stack in different order in C vs C++.
REALLY?!
[..].
My info may be out of date, but C pushes the args
in left-to-right order (allowing support for a variable
number of args), and C++ uses the Pascal-style
of right-to-left order.
So, this suggests that C++ has no support for a variable number of rags.
Is that so?
The order of the args on the
stack is (was in the 80's) standardized to allow libs
from multiple vendors to inter-operate.
As I recall, in C the calling code cleans up the call stack
after a function call returns, but in C++ the called
function cleans up the call stack before returning.
I think you've confused C++ with Pascal.
V
A long time ago in a galaxy far, far away, my job was to write
asm code to interface with both C and C++.
Page 3 in the following doc provides a brief summary of the
call stack procedures:
http://www.nuvisionmiami.com/books/a...s/CppCalls.pdf
The example asm module discussed uses the C calling convention
(push args in reverse order, caller cleans up the stack after
the called function returns). Note that the functions discussed
are all declared 'extern "C"' in the C++ code to advise the
compiler that these functions use the C call stack layout
rather than the C++ call stack layout.
Following is another doc describing the differences between the
C and C++ call stack layouts. Although this doc is MS VC specific,
variations of the '__cdecl' and 'thiscall' stack layouts are
used on most OS'es. The '__cdecl' style stack is used for C
functions and C++ functions with variable arg list, and the
'thiscall' style stack is used for C++ functions that do not
have a variable arg list.
http://www.codeproject.com/cpp/calli...emystified.asp
Regards,
Larry