IT lexicon › Programming › cdecl

cdecl

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

The default C calling convention on 32-bit x86: every argument on the stack, and the caller cleans up afterwards.

Arguments are pushed right to left, so the first one ends up nearest the return address. Results come back in eax, 64-bit integers in edx:eax, floating point in the x87 register st0. Once the call returns, the caller adjusts the stack pointer itself with add esp, N. That costs a few bytes at every call site, but it is exactly what makes printf possible: only the caller knows how many arguments it actually passed.

The name is short for C declaration, and the convention was never formally standardised, so compilers disagree on details like stack alignment and how structs are returned. On Windows the symbols get a leading underscore, _foo. On x86-64 cdecl is effectively history; the keyword is accepted and silently ignored.

← Back to the lexicon