va_list used in <stdio.h>

Walter Bright bright at Data-IO.COM
Tue Aug 15 05:13:23 AEST 1989


In article <1140 at midgard.Midgard.MN.ORG> dal at midgard.Midgard.MN.ORG (Dale Schumacher) writes:
<I'm working on the header files for a PD LIBC implementation with the
<goal that it be as close as possible to X3J11 and POSIX conformance.
<I'm working from the May 13, 1988 draft of the C pANS.

Finally! Instead of wasting energy worrying about the GNU copyright,
you've got the right idea! Best of luck to you!

<In the <stdio.h> header file, the v[fs]printf() function prototypes
<use the va_list type, but va_list is not defined anywhere in <stdio.h>.

The trick to note is that <stdarg.h> is required for any *user* code that
uses variable argument lists. Since <stdio.h> is supplied by the *vendor*,
the problem can be solved in one of two ways,

1. In stdio.h, include the lines:
	#ifndef __STDARG_H		/* #define'd by stdarg.h	*/
	#include <stdarg.h>		/* get definition of va_list	*/
	#endif
   (As has been discussed here before, using 'wrappers' like this means
    that order dependent #include's can be #include'd in any order
    without a problem.)

2. As the compiler vendor, we *know* what va_list is, so we simply prototype
   vprintf and friends as:
	int vprintf(const char *,char *);
   instead of:
	int vprintf(const char *,va_list);

I use 2. because it compiles faster.



More information about the Comp.lang.c mailing list