HP-UX Reference (11i v2 07/12) - 5 Miscellaneous (vol 9)

v
varargs(5) varargs(5)
* a second file pointer has been passed in to print general
* message information to. The rest of the format string is
* a standard printf(3S) format string.
*/
if ((*fmt == ’%’) && (*(fmt + 1) == ’Y’))
{
FILE *other_fp;
fmt += 2;
other_fp = (FILE *) va_arg(ap, char *);
if (other_fp != (FILE *) NULL)
{
/*
* Print general message information to additional stream.
*/
(void) vfprintf(other_fp, fmt, ap);
(void) fflush(other_fp);
}
}
/*
* Now print it to the log file.
*/
(void) vfprintf(log_fp, fmt, ap);
}
WARNINGS
It is up to the calling routine to specify how many arguments there are, because it is not always possible to
determine this from the stack frame. For example, execl() is passed a zero pointer to signal the end of
the list. printf() can determine how many arguments are present by the format.
It is non-portable to specify a second argument of char, short,or float to
va_arg, because argu-
ments seen by the called function are not
char, short,orfloat. C converts
char and short argu-
ments to
int, and converts float arguments to double, before passing them to a function.
SEE ALSO
exec(2), vprintf(3S), stdarg(5).
STANDARDS CONFORMANCE
va_alist: AES, SVID2, SVID3, XPG2, XPG3, XPG4
va_arg: SVID2, SVID3, XPG2, XPG3, XPG4
va_dcl: SVID2, SVID3, XPG2, XPG3, XPG4
va_end: SVID2, SVID3, XPG2, XPG3, XPG4
va_list: SVID2, SVID3, XPG2, XPG3, XPG4
va_start: SVID2, SVID3, XPG2, XPG3, XPG4
<varargs.h> : AES, SVID3, XPG2, XPG3, XPG4
494 Hewlett-Packard Company 3 HP-UX 11i Version 2: December 2007 Update