ralf@ptavv.ka.sub.org (Ralf Wenk) (02/06/91)
Hello *,
could someone explain what I am doing wrong ?
The following call of vfprintf() will cause a core dump when doing
_doprintf(). My system is MINIX ST 1.5.10.2.
#include <stdarg.h>
#include <stdio.h>
FILE *log;
char line[LINESIZE+1];
void lprintf ( ctl, argp )
char *ctl;
va_list argp;
{
vfprintf( log, ctl, argp );
} /* lprintf */
Down in the source lprintf() is called like this:
lprintf("batch from %s", line );
Is is also interesting, that changing the call to vfprintf( log, ctl, &argp )
will fix it. Do I misunderstand how to use stdarg.h or is this an MINIX ST
problem ?
I just use it the way vsprintf() uses it.
Many thanks,
Ralf Wenk
--
--
Ralf Wenk -- ralf@ptavv.ka.sub.org
hp@vmars.tuwien.ac.at (Peter Holzer) (02/10/91)
ralf@ptavv.ka.sub.org (Ralf Wenk) writes: >#include <stdarg.h> >#include <stdio.h> >FILE *log; >char line[LINESIZE+1]; >void lprintf ( ctl, argp ) >char *ctl; >va_list argp; >{ > vfprintf( log, ctl, argp ); >} /* lprintf */ >Down in the source lprintf() is called like this: >lprintf("batch from %s", line ); >Is is also interesting, that changing the call to vfprintf( log, ctl, &argp ) >will fix it. Do I misunderstand how to use stdarg.h or is this an MINIX ST >problem ? >I just use it the way vsprintf() uses it. You do misunderstand how to use stdarg.h. Your function should read: void lprintf (ctl) char *ctl; { va_list argp; va_start (argp, ctl); vfprintf( log, ctl, argp ); va_end (argp); } /* lprintf */ Actually, the function header should be void lprintf (char * ctl, ...), but as Minix-cc isn't ANSI yet, you can't do this. -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |