Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!samsung!ginosko!aplcen!haven!adm!xadmx!mark@spider.co.uk From: mark@spider.co.uk (Mark Valentine) Newsgroups: comp.unix.wizards Subject: calling one varargs routine from another (how?!) Message-ID: <21293@adm.BRL.MIL> Date: 27 Oct 89 17:56:13 GMT Sender: news@adm.BRL.MIL Lines: 60 [If I had USENET postability this would be in comp.lang.c. But I don't think it's entirely a waste of bandwidth here...] Q: Is there a portable way, both in ANSI and traditional C, to call a varargs function such as void error(char *message, ...) from another such as void fatal(char *message, ...) ? For traditional C, my best guess would be something like #include void fatal(va_alist) va_dcl { error(va_alist); exit(1); } (which actually worked for my test prog on a MIPS box, but not on a VAX). For ANSI C, the nearest I can get to expressing what I want is #include void fatal(char *message, ...) { va_list args; va_start(args, message); error(message, args); va_end(args); exit(1); } which doesn't work on either the MIPS or VAX! My test was main() { fatal("%d... %d... %d... bye!\n", 3, 2, 1); } I feel I'm missing something, but... It would niggle me to expand a six-line error routine in each of a handful of wrappers! On the other hand I guess if this were possible we wouldn't have v*printf(). #if 0 A: #endif Mark. -- Mark Valentine, Spider Systems /\oo/\