[lug] varargs.h stdarg.h

Gary Hodges Gary.Hodges at noaa.gov
Mon Apr 25 16:25:48 MDT 2005


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
{
  va_list args;
  FILE    *fp;
  int     line;
  char    *format, *file, out_str[512];

  va_start(args);

  /* get file pointer */
  fp = va_arg(args, FILE *);
  if(fp == NULL)
    return(0);

The errors:
xprintf.c:26: error: parse error before "va_dcl"
xprintf.c:27: error: syntax error before '{' token
xprintf.c:33:16: macro "va_start" requires 2 arguments, but only 1 given
xprintf.c:33: warning: type defaults to `int' in declaration of `va_start'
xprintf.c:33: warning: data definition has no type or storage class
xprintf.c:36: warning: type defaults to `int' in declaration of `fp'
xprintf.c:36: error: conflicting types for `fp'
xprintf.c:29: error: previous declaration of `fp'
xprintf.c:36: error: `args' undeclared here (not in a function)
xprintf.c:36: warning: data definition has no type or storage class
xprintf.c:37: error: parse error before "if"








More information about the LUG mailing list