Using varargs.h with C++ <iostream>

Carlo Wood carlo@runaway.xs4all.nl
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
| 
| jstern@citilink.com

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>:

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

COMPATIBILITY
       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  <carlo@runaway.xs4all.nl>



More information about the Gcc mailing list