Portable mini-vfprintf?

Jef Poskanzer jef at well.sf.ca.us
Sat Jun 29 10:08:49 AEST 1991


I have this large software package, pbmplus, which I would like to be
as portable as possible.  It has a unified message and error routine
called pm_message, which really ought to be a varargs routine.  The
problem is doing this portably.  I can deal with varargs.h vs. stdarg.h
easily enough, but what about the substantial minority of systems out
there which don't have vfprintf?

The proposed skeleton of the portable version is appended.  If you can
think of a way to do this without needing to supply a vfprintf, I'd
love to hear about it.  Otherwise, do you have a vfprintf lying around?
---
Jef

  Jef Poskanzer  jef at well.sf.ca.us  {apple, ucbvax, hplabs}!well!jef
                               "Swell."

#if __STDC__
static void
pm_message( char* fmt, ... )
    {
    va_list ap;

    va_start( ap, fmt );
#else /*__STDC__*/
/*VARARGS1*/
static void
pm_message( va_alist )
    va_dcl
    {
    va_list ap;
    char* fmt;

    va_start(ap);
    fmt = va_arg( ap, char* );
#endif /*__STDC__*/

    (void) vfprintf( stderr, fmt, ap );
    va_end( ap );
    }

#ifdef NEED_VFPRINTF
    /* portable mini-vfprintf goes here */
#endif /*NEED_VFPRINTF*/



More information about the Comp.lang.c mailing list