Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!hpa From: hpa@casbah.acns.nwu.edu (Peter Anvin) Newsgroups: comp.lang.c Subject: Void function pointers Summary: Can one pass non-void function arguments to functions expecting void? Keywords: void,function,pointer,ansi,c Message-ID: <2887@casbah.acns.nwu.edu> Date: 24 Jan 91 05:28:58 GMT Distribution: usa Organization: Northwestern University Lines: 34 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@casbah.acns.nwu.edu FIDONET: 1:115/989.4 BITNET: HPA@NUACC RBBSNET: 8:970/101.4