IT lexicon › Programming › thiscall

thiscall

Programming På svenska → Updated: 2026-11-05

Microsoft's calling convention for C++ member functions on 32-bit x86, which passes the hidden this pointer in ecx.

Every non-static member function takes an invisible first argument: the object it was called on. MSVC puts it in ecx, pushes the remaining arguments right to left and has the callee clean up the stack, just like stdcall. A member function with a variable argument count cannot know in advance how much to pop, so it falls back to cdecl with this pushed onto the stack.

GCC on 32-bit Linux long did it differently, passing this as an ordinary first stack argument, one more reason C++ libraries from different compilers refused to mix. COM sidesteps the issue by declaring its interface methods stdcall. On x86-64 there is no thiscall at all: this is simply the first argument, in rcx or rdi.

← Back to the lexicon