A sincere thanks for your response and clarification. In response to why, yes, I have cases where g++ code will call MSVC code (or vice versa). Currently, as explained below, it doesn't work due to the this pointer on the stack. I tried changing the calling convention (cdecl, stdcall, fastcall) to no avail. Any other ideas?
Thanks, Dev1024 Paul Pluzhnikov wrote: > "Dev1024" <[EMAIL PROTECTED]> writes: > > > Having been a long time user of Microsoft Visual C++ .Net 2003 (MSVC), > > I've recently been using g++ on a project. I've found a difference > > between the two compilers when calling a virtual function that has me > > puzzled. > > The immediate question is "why do you care?" > > > The issue is when calling virtual functions. In MSVC the parameters > > are pushed on to the stack as expected and then the address of the > > function is loaded into EAX. Finally "call EAX" is issues to call the > > virtual function. > > That is incorrect: you are missing a step: loading "this" into %esi. > > > In g++ (Cygwin g++ v3.4.4) the parameters are pushed > > onto the stack as expected, but then a pointer (32 bit pointer in my > > case) to the vtable is pushed on the stack as well > > That is also incorrect: it's the "this" parameter that is pushed. > However, since g++ puts the vtable at the start of any class with > virtual functions, the "this" and &vtbl are the same thing. > > > - Why does g++ load a pointer to the vtable on the stack after pushing > > on the params? > > It doesn't. It simply passes all parameters (including "this") > on the stack. > > > - Is there a compiler option that can be used to avoid putting a > > pointer to the vtable on the stack? (I looked but couldn't find one.) > > These are implementation details, best left alone. > Are you trying to link together MSVC and g++ compiled code? > > Cheers, > -- > In order to understand recursion you must first understand recursion. > Remove /-nsp/ for email. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus