varargs and X

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Sep 7 14:11:41 AEST 1989


In article <19199 at gatech.edu> ken at gatech.edu (Ken Seefried III) writes:
>Widget Error( parent, va_list )
>	Widget parent;
>        va_dcl
>{
>va_list         vaargs;
>char            *fmt;
>        va_start( vaargs );
>        fmt = va_arg( args, char * );
>        vsscanf( buffer, fmt, vaargs );
>Anyone have any insight into the deep dark mysteries of varargs?

Yes.  There are several problems here.  The first is that correct usage
of varargs requires that the function definition start off like:

Widget Error( va_alist )
	va_dcl
{
va_list		vaargs;
Widget		parent;
char		*fmt;
	va_start( vaargs );
	parent = va_arg( vaargs, Widget );
	fmt = va_arg( vaargs, char * );

Notice several differences, especially the use of va_alist (NOT va_list!).

The second problem is that vsscanf() doesn't normally exist in C libraries.
Therefore you'll have to provide one..



More information about the Comp.lang.c mailing list