Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!olivea!uunet!abvax!iccgcc!browns From: browns@iccgcc.decnet.ab.com (Stan Brown) Newsgroups: comp.lang.c Subject: Re: Void function pointers Message-ID: <2935.279ee6c2@iccgcc.decnet.ab.com> Date: 24 Jan 91 18:53:06 GMT References: <2887@casbah.acns.nwu.edu> Distribution: usa Lines: 28 In article <2887@casbah.acns.nwu.edu>, hpa@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@ab.com -or- browns@iccgcc.decnet.ab.com Stan Brown, Oak Road Systems, Cleveland, Ohio, USA +1 216 371 0043