IT lexicon › Programming › Variadic function

Variadic function

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

A function that takes a varying number of arguments, like C's printf, declared with an ellipsis ... at the end of its parameter list.

In C the arguments are fetched with va_start, va_arg and va_end from stdarg.h. No type information comes along; the function has to trust the format string or some other convention, and if that is wrong it reads garbage. The arguments also go through the default promotions: char and short become int, float becomes double.

At the ABI level they are a special case of their own. System V on x86-64 has the caller report in al how many vector registers are in use, and Apple's ARM64 ABI puts every variadic argument on the stack. Code that called variadic functions through non-variadic prototypes worked by accident on x86 and broke on Apple Silicon. C++ prefers variadic templates, which are type-safe.

← Back to the lexicon