varargs -> stdarg
Posted: Fri Nov 17, 2023 8:31 am
As the C compiler release notes strongly recommends using stdarg instead of varargs then I thought I should have a look at my code that uses varargs.
Consider the following utility function that I use in several of my programs.
Any thoughts on how to change it to use stdarg?
Consider the following utility function that I use in several of my programs.
Any thoughts on how to change it to use stdarg?
Code: Select all
void
putmsg(ccode,va_alist)
unsigned long ccode;
va_dcl
{
unsigned long args[20], *argp;
va_list ap;
int nargs;
unsigned short fac;
fac = $VMS_STATUS_FAC_NO(ccode);
va_start(ap);
va_count(nargs);
args[0] = nargs--;
args[1] = ccode;
if (fac == SYSTEM$_FACILITY || fac == RMS$_FACILITY)
argp = &args[2];
else
{
args[2] = nargs;
argp = &args[3];
}
while (nargs-- > 0)
*argp++ = va_arg(ap,unsigned long);
va_end(ap);
SYS$PUTMSG(args,(void(*)())put_output,0,0);
}