Void function pointers
Peter Anvin
hpa at casbah.acns.nwu.edu
Thu Jan 24 16:28:58 AEST 1991
Hello everyone. Could someone please tell me if this is illegal in ANSI C,
or if only Turbo C++ is picky:
void foo(int p1, double p2, void (*zoom)(int x, double y))
{
printf("Do something with %d and %ld\n",p1,p2);
zoom(p1,p2);
}
int bar(int baz, double quux)
{
printf("Zooming... %lf\n",quux);
return baz;
}
main()
{
foo(7,3.141592653938789,bar); /* Turbo C++ gives hard error here */
return 0;
}
Turbo C++ always terminates with a hard "Type mismatch" error. Is this
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?
Grateful for answer.
/Peter
P.S. I haven't been able to figure out... is X3J11 ANSI C *finalized* (ANSI
C-90) or are we still muddling around with working drafts?
--
H. Peter Anvin +++ A Strange Stranger +++ N9ITP/SM4TKN +++
INTERNET: hpa at casbah.acns.nwu.edu FIDONET: 1:115/989.4
BITNET: HPA at NUACC RBBSNET: 8:970/101.4
More information about the Comp.lang.c
mailing list