Type of function returning function.

Matthias Ulrich Neeracher mneerach at inf.ethz.ch
Wed Jul 11 20:59:44 AEST 1990


In article <1990Jul10.024205.17382 at media.uucp> rmf at media.uucp (Roger Fujii) writes:
>So, just how does one type a function returning a pointer to a function?
>(other than the obvious void *)
>Example:
>int foo(buff)
>char	*buff;
>{
>	return atoi(buff);
>}
>
>TYPE bar()
>{
>	return foo;
>}

I always program things like this using an intermediate typedef :

typedef int (*MyProcType)(); 

MyProcType bar() { return foo; } 

or more ANSI-like :

typedef int (*MyProcType)(char);

MyProcType bar() { return foo; }

I don't know how to declare functions like this directly; I don't care.
Why make you life unnecessarily hard ?

Matthias



More information about the Comp.lang.c mailing list