prev up next   top/contents search

comp.lang.c FAQ list · Question 15.1

Q: I heard that you have to #include <stdio.h> before calling printf. Why?


A: So that a proper prototype for printf will be in scope.

A compiler may use a different calling sequence for functions which accept variable-length argument lists. (It might do so if calls using variable-length argument lists were less efficient than those using fixed-length.) Therefore, a prototype (indicating, using the ellipsis notation ``...'', that the argument list is of variable length) must be in scope whenever a varargs function is called, so that the compiler knows to use the varargs calling mechanism.

References: ISO Sec. 6.3.2.2, Sec. 7.1.7
Rationale Sec. 3.3.2.2, Sec. 4.1.6
H&S Sec. 9.2.4 pp. 268-9, Sec. 9.6 pp. 275-6


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North