Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!genrad!panda!talcott!harvard!seismo!vrdxhq!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: ANSI C and function prototypes Message-ID: <250@hadron.UUCP> Date: Mon, 10-Feb-86 23:11:44 EST Article-I.D.: hadron.250 Posted: Mon Feb 10 23:11:44 1986 Date-Received: Thu, 13-Feb-86 17:36:42 EST References: <681@harvard.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 23 Summary: (void *) in spcl cases; else union. In article <681@harvard.UUCP> steve@harvard.UUCP (Kaufer - Lopez - Pratap) writes: > Let's say I want to write a 'dispatcher' routine that is >passed a code number and a pointer to a function to call. >I wish to use a prototype to make sure that I am always passing >two arguments, the first of which is an int and the >second of which is a function pointer. > I might define the prototype as: > dispatcher(int code, void (*disp_func)()); > Is there any way to prototype the second argument as a pointer to >a function returning 'anything'? If 'anything' is limited to pointers, you can say: int dispatcher(int code, void *(*disp_func)()); as I understand it. (If you are going to explicitly declare the arguments to your functions, then by all means declare the function itself!!) Otherwise, if you want to include scalars and structures, you must build a union and have the prototype return that. Of course, since no one but EcoSoft (tentative as that is) has prototyping, there's no compiler to check this against. (I don't have EcoSoft C.) -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}