vprintf()
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Jul 31 11:15:38 AEST 1990
In article <1990Jul30.182656.19169 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>In article <13450 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>>>>Is vprintf() mandated to be in <stdio.h> by ANSI C...
>>>Yes. (Although you have to include <stdarg.h> as well.)
>>You don't have to include <stdarg.h> to get vprintf() properly defined,
>>just <stdio.h>...
>Can you prove this? Unless this got changed since the late draft that
>is all I've got (must get a copy of the final standard, sigh...), the
>specs for the v* functions all call for <stdarg.h> before <stdio.h>.
>On a quick search, I find no explicit statement to the effect that
>either (a) <stdio.h> suffices, or (b) <stdarg.h> is required.
4.1.2.1 states that the header for the section (4.9, i.e. <stdio.h>)
declares or defines all identifiers listed for its section; it doesn't
say or imply that it may need any help in doing so. The "Synopsis"
subsections are just a funny sort of pseudo-source method of showing
what the function interfaces are like; in fact, as 4.1.6 points out,
in most cases the functions can be declared without use of any
standard header. The reason for <stdarg.h> in the v*printf() Synopses
is that the interface is shown in terms of the va_list type, and
inclusion of <stdarg.h> is the only method by which a strictly
conforming application could get that type defined. Note, however,
that a conforming implementation must NOT naively invoke <stdarg.h>
to obtain a definition for va_list for use in the v*printf()
declarations within <stdio.h>. This was explained in the response to
a letter in the third round of public review of the draft proposed
standard:
Response to Letter 185 (X3J11/88-145) issue summarized as
"va_list must also be defined in stdio.h>":
va_list need not, indeed must not, be defined in <stdio.h>.
typedefs do not create new types, merely synonyms for other
types. In <stdio.h> function prototypes an implementation
has to use the type that it would define for va_list in
<stdarg.h>. For example, if a void * is chosen for va_list,
the prototype for vprintf, vfprintf, and vsprintf would just
use void *.
This question has come up several times, and that has always been the
response.
More information about the Comp.std.c
mailing list