[comp.lang.c] type of function

paul@cs.utexas.edu (Supoj Sutanthavibul) (08/18/89)

How would one declare a function which returns a pointer to a function
which return void?  To clarify this question, here is an example.  The
question is: what is the type of get_func()?  Or, how would it be declared
in another function that calls it?

	void
	foo1()
	{
		...
		}

	void
	foo2()
	{
		...
		}

	.
	.
	.

	void
	fooN()
	{
		...
		}

	get_func(which)
	int	which;
	{
		if (... which ... ) return(foo1);
		...
		else if (... which ... ) return(fooN);
		}

chris@mimsy.UUCP (Chris Torek) (08/18/89)

In article <813@lychee.cs.utexas.edu> paul@cs.utexas.edu
(Supoj Sutanthavibul) writes:
>How would one declare a function which returns a pointer to a function
>which return void?

% cdecl
declare foo as function (args) returning pointer to function returning void
void (*foo(args))()

(Actually, I cheated: our cdecl does not like `void', so I used `int'
and then changed its output.)

Some C compilers cannot handle `void *' or even (in some situations)
`void (*)()'.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris