Varargs problem
Chris Torek
chris at mimsy.UUCP
Sat Aug 26 10:04:09 AEST 1989
In article <4YxPuc200VsnE_B3Jy at andrew.cmu.edu> bobg+ at andrew.cmu.edu
(Robert Steven Glickstein) writes:
>I wish to extract a variable of type "pointer to function returning int"
>[(int (*) ())] from a varargs parameter list, and I can't.
> fn = va_arg(ap, int (*) ());
va_arg must be handed a type that can legally have one `*' added on the
end; int (*)() is not such a type.
The solution is to create a typedef:
typedef int (*intfn_t)();
...
fn = va_arg(ap, intfn_t);
With one small change (`typedef int (*intfn_t)(void)') one gets an ANSI-
style extraction. (Alas, the `va_start' invocations and function
declarations must be changed.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list