[lug] varargs.h stdarg.h

Lori Reed lorireed at lightning-rose.com
Mon Apr 25 16:45:40 MDT 2005


Gary Hodges wrote:
> I'm trying to get some C code to compile and have run into an issue.  It 
> seems varargs.h is no longer supported and a compile error suggested 
> changing to stdarg.h.  I've done that, but it results in a bunch of 
> errors that mostly seem syntax related.  I've tried changing code based 
> on a few searches, but being almost completely C illiterate, I'm not 
> making much progress.  The entire thing is only about 50 lines.  I'm 
> including a short section that is producing some errors and am hoping I 
> can get some guidance (Lines 25-39).  I'm told this compiled fine with 
> RHL 7.0.
> int xprintf( va_alist )
>  va_dcl
> {

First, the va_cl should go.

Perhaps an example will help. Here's a function I wrote that prints an 
error message (with a format string and params) to stderr and then exits 
the program with an error code.

#include  <stdarg.h>

void    bugOut( int errorCode, char *formatString, ... )
{
      va_list args;

      fflush( stdout );

      va_start( args, formatString );

      vfprintf( stderr, formatString, args );

      va_end( args );

      exit( errorCode );
}

Regards,
Lori




More information about the LUG mailing list