varargs...help appreciated
Ken Lerman
lerman at stpstn.UUCP
Tue Nov 6 08:13:49 AEST 1990
In article <27416 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
...
[->> has lost attribution.]
->>p.s. Anyone got any varargs macros, portable between
->> traditional varargs and ANSI stdarg?
->
->If you mean what I think you mean, it cannot be done. The reason
->is that `va_start' has the same name in <varargs.h> and <stdarg.h>
->but the former version (used above) has only one parameter while the
->latter has two. It is thus impossible to write a single implementation.
->
->If you mean the other thing I think you mean, it can be done, but it
->looks horrible (and I will not even give an example).
->--
->In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
->Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
I generally put the following in my code (by #include):
#if defined(__STDC__) && __STDC__ != 0
#include <stdarg.h>
#define VA_START(ap,last) va_start(ap,last)
#else
#include <varargs.h>
#define VA_START(ap,last) va_start(ap)
#endif
Then I can write VA_START(ap, lastArg) in my code as if I'm using the
ANSI style of va_start.
While this is not a single va_start which does both, I think it meets
the portablility goals which were stated.
Ken
More information about the Comp.lang.c
mailing list