Article View: comp.std.c
Article #904Re: varargs vs. stdargs
From: Maarten Litmaath
Date: Tue, 14 Nov 1989 16:31
Date: Tue, 14 Nov 1989 16:31
51 lines
1590 bytes
1590 bytes
How about this?
--
/*
* my_varargs.h
*/
#ifndef MY_VARARGS_H
#define MY_VARARGS_H
#ifdef __STDC__
#define EXTERN_VARARGS(type, f, args) extern type f args
#define VARARGS(type, f, args) type f args
#define VA_START(ap, type, start) va_start(ap, start)
#include <stdarg.h>
#else /* __STDC__ */
#define EXTERN_VARARGS(type, f, args) extern type f()
#define VARARGS(type, f, args) type f(va_alist) \
va_dcl
#define VA_START(ap, type, start) va_start(ap); \
start = va_arg(ap, type)
#include <varargs.h>
#endif /* __STDC__ */
#endif /* !MY_VARARGS_H */
--
In somefile.h:
--
EXTERN_VARARGS(void, error, (error_p_type error, ...));
--
In somefile.c:
--
/* VARARGS1 */
VARARGS(void, error, (error_p_type error_p, ...))
{
#ifndef __STDC__
error_p_type error_p;
#endif /* !__STDC__ */
va_list ap;
VA_START(ap, error_p_type, error_p);
vfprintf(stderr, error_p->message, ap);
va_end(ap);
exit(error_p->status);
}
--
[...] like a roving gang. "Ah, here's a NEW almost-empty group to post train
schedules and core dumps in!" (Joe Buck) | maart@cs.vu.nl, mcsun!botter!maart
Technical Details
Message-ID:
<4537@ski.cs.vu.nl>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!aplcen!uunet!mcsun!hp4nl!botter!star.cs.vu.nl!maartReferences:
<GNB.89Nov14103800@baby.bby.oz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!aplcen!uunet!mcsun!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.std.c Subject: Re: varargs vs. stdargs Message-ID: <4537@ski.cs.vu.nl> Date: 14 Nov 89 16:31:05 GMT References: <GNB.89Nov14103800@baby.bby.oz> Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatica, Amsterdam Lines: 51