ANSI C and function prototypes

Joseph S. D. Yao jsdy at hadron.UUCP
Tue Feb 11 14:11:44 AEST 1986


In article <681 at harvard.UUCP> steve at 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 at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list