James Kanze said:
How can it? Things like the layout of the vtable are part of
the calling conventions, and C++ can't possibly use the same
ones as C here.
simply:
C doesn't have vtables (or, at least, compiler generated ones);
in the C++ case, they are structures.
effectively, then, vtables are part of the ABI, but are not part of the
calling convention.
Except on Intel, the first argument *is* usually in a register.
not in cdecl or stdcall...
cdecl and stdcall tend to pass *everything* on the stack.
64-bit Windows and Linux pass arguments in registers.
fastcall also uses registers, but fastcall is rarely the default convention
(usually it has to be specified manually).
thiscall (typical on Windows) passes 'this' in ecx, but AFAIK this does not
extend to any other (non-this) arguments.
That's not true, and I've done it on many platforms.
something can easily "work" in many cases, but still not be "safe" in a
portability sense.
if one can do it, they can declare that it "works on most platforms of
interest", which may exclude some edge cases (for example, most PC or server
targetted code will not work on embedded systems, ...).
as for C++ ABI's, the main issue is that MSVC and MinGW on Windows use
different C++ ABI's, and so if one wants to support use of either compiler
(with pre-existing binary code), it is best to avoid using C++ as a basis
for API's.
other compilers tend to have other ABI's as well, and so this leaves the C
ABI as the "most portable" option.
using 'extern "C"' generally works without issue though, so long as one
fully adheres to C restrictions at the API level.
MSVC does what you tell it in this regard. If you tell it to
give each DLL its own local C library, when you don't want to,
it's nobody's fault but your own.
this is the default behavior.
one has to tell it to do otherwise, but then it uses 'msvcr80.dll', which
has to be supplied manually on WinXP.
I don't know about MinGW or Cygwin, but under most Unix, it's
also possible to arrange things so that each shared object has
its own free space arena as well, if this is what you want.
yes, but this is not necessarily a desirable feature, and is actually kind
of annoying sometime...