On 10/27/2012 02:18, mathog wrote:
On 26-Oct-2012 10:21, JonY wrote:
Take note that 4.7.x series is now defaulting to __thiscall call convention for C++ member methods. In short, C++ code built by previous versions will NOT work.
Is there some reason not to set a compiler flag to make 4.7.x use the same call convention as the older 4.6.x? Is there any advantage for either the developers or the end users in using the newer call convention?
No, there is no such flag.
Neither would it be practical to implement it, the libstdc++ C++ library used by GCC will not work with a different call convention it was built with.
As for advantages, there aren't any clear performance winners other than a slight increase in MSVC compatibility.
The previous call convention is __cdecl[1], arguments pushed to stack right to left, caller unwinds the stack. This convention is used by Linux SysV ABI and normal C code on Linux and Windows. __thiscall[2] is a C++ variant of __stdcall[3] where stack is unwound by callee, however the "this" C++ context is put on the ECX register rather than as a normal first call argument.
GCC unfortunately does not mangle __cdecl vs __thiscall call convention into the object symbol tables, this meant you can still link your old code, but it would fall apart during runtime.
[1] http://msdn.microsoft.com/en-us/library/zkwh89ks.aspx [2] http://msdn.microsoft.com/en-us/library/ek8tkfbw.aspx [3] http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx