Void function pointers

Stan Brown browns at iccgcc.decnet.ab.com
Fri Jan 25 05:53:06 AEST 1991


In article <2887 at casbah.acns.nwu.edu>, hpa at casbah.acns.nwu.edu (Peter Anvin) writes:
> 
> void foo(int p1, double p2, void (*zoom)(int x, double y))

So the third argument to 'foo' will be [the name of] a function that does
not return a value.
 
> int bar(int baz, double quux)

Function 'bar' returns an int.

>    foo(7,3.141592653938789,bar);         /* Turbo C++ gives hard error here */

But when you called 'foo' you gave it an int function as third argument.
Returning something is not the same as returning nothing.

> Turbo C++ always terminates with a hard "Type mismatch" error.  Is this

As it should, IMHO.

> correct behaviour, and if so, is there a way to declare a pointer to a
> function returning *anything or void* but still specify its parameters?

I'm 99% sure the answer is No.  A thing is not the same as nothing.

Hey--this is all my opinion, nobody else's. Rely on it at your peril.
                email: browns at ab.com -or- browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA    +1 216 371 0043



More information about the Comp.lang.c mailing list