Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!indri!ames!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Varargs problem Message-ID: <19271@mimsy.UUCP> Date: 26 Aug 89 00:04:09 GMT References: <4YxPuc200VsnE_B3Jy@andrew.cmu.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 In article <4YxPuc200VsnE_B3Jy@andrew.cmu.edu> bobg+@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@mimsy.umd.edu Path: uunet!mimsy!chris