Using varargs.h with C++ <iostream>

Carlo Wood
Wed Sep 2 10:24:00 GMT 1998

| The <varargs.h> header does some work to #undef# conflicts
| from <stdarg.h>, but the reverse doesn't seem to be true.
| Also, <iostream> eventually includes <stdarg.h> through
| streambuf.h
| This results in a situation where <varargs.h> will work
| properly if it is included after <iostream> but not if it
| is included before.  Is this intended?
| (all of the above observations are made wrt the 8/24 snapshot)
| - Josh

I think that the answer is that <varargs.h> is not compatible
with <iostream> anyway.

<varargs.h> is not ANSI, its an old set of macros that have
been replaced by <stdarg.h>.  <varargs.h> is only there
for backwards compatibility but should be avoided if possible.

>From the manual of <stdarg.h>:

       The  va_start,  va_arg,  and va_end macros conform to ANSI
       C3.159-1989 (``ANSI C'').

       These macros are not compatible with the  historic  macros
       they  replace.  A backward compatible version can be found
       in the include file varargs.h.

 Carlo Wood  <>

More information about the Gcc mailing list