home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!vela!pd-dom!agrafiot
- From: agrafiot@wl.com (Dimitris Agrafiotis)
- Subject: Re: questions on variable argument lists
- Message-ID: <1992Dec14.203422.5537@wl.com>
- Sender: agrafiot@wl.com
- Organization: Warner Lambert / Parke-Davis
- References: <1992Dec14.195419.4785@wl.com>
- Distribution: usa
- Date: Mon, 14 Dec 1992 20:34:22 GMT
- Lines: 41
-
- In article <1992Dec14.195419.4785@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
- >
- >I want to define a function, alpha(), that takes as arguments a pointer to a
- >function, beta(), and the arguments to be passed to that function. Ideally,
- >the function would be implemented as follows:
- >
- >void alpha(void (*beta)(...), ...)
- >{
- > va_list arg;
- > va_start(arg, beta);
- > (*beta)(arg);
- > va_end(arg);
- >}
- >
- >but that doesn't work for several reasons. First, the compiler seems to
- >require at least one argument in the declaration of beta(). Is there
- >an elegant way around that ? Second, even when you avoid this problem
- >by introducing a dummy argument, you get garbage at run time (this was
- >run on an SGI Indigo). What is the reason? What's the best alternative
- >and how portable would it be?
- >Thanks in advance,
- >
- >--
- >Dimitris K. Agrafiotis
- >Computer Assisted Drug Design
- >Parke-Davis Pharmaceutical Research
- >(agrafiot@wl.com)
-
- I did some experiments and I think I found the solution to my problem
- (at least on the SGI machines). The declaration would be something like:
-
- void alpha(void (*beta)(va_list arg), ...);
-
- and the rest is obvious. Sorry for waisting your time.
-
-
- --
- Dimitris K. Agrafiotis
- Computer Assisted Drug Design
- Parke-Davis Pharmaceutical Research
- (agrafiot@wl.com)
-