### Question 15.3

I had a frustrating problem which turned out to be caused by the line

    	printf("%d", n);

where `n` was actually a `long int`. I thought that ANSI function prototypes were supposed to guard against argument type mismatches like this.

When a function accepts a variable number of arguments, its prototype does not (and cannot) provide any information about the number and types of those variable arguments. Therefore, the usual protections do not apply in the variable-length part of variable-length argument lists: the compiler cannot perform implicit conversions or (in general) warn about mismatches.

See also questions 5.2, 11.3, 12.9, and 15.2.

Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995 // mail feedback