ANSI C and function prototypes

Pratap steve at harvard.UUCP
Wed Feb 5 06:01:19 AEST 1986


	Here is a short question regarding the new ANSI standard and 
function prototypes.

	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)());

	My problem is that under the standard it will always be an error to 
call this routine with a pointer to a function that does NOT return void.

	Is there any way to prototype the second argument as a pointer to
a function returning 'anything'?  I realize if I prototype the second
argument as a 'void *pointer', any pointer will be properly converted, 
but this defeats my purpose of checking to make sure that the second
argument is really a function pointer.

	I can think of many times when I have passed pointers to functions 
that return various different types, yet I see no way of doing this when
using prototypes.  

		Steve Kaufer
		steve at harvard.HARVARD.EDU
		{seismo,ihnp4,allegra,ut-sally}!harvard!steve



More information about the Comp.lang.c mailing list