Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Casting Function Pointers Message-ID: <16248@smoke.brl.mil> Date: 23 May 91 20:13:10 GMT References: <1145@mwtech.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 16 In article <1145@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: > "The elaborate cast of the function argument casts the > arguments of the comparison function. These will generally > have no effect on actual representation but assure the > compiler that all is well." K&R2 was written before the final ANSI C standard was published. In fact, at the time it was written it was technically wrong on this point. However, since then X3J11 decided to require void* and char* to have the same representation, and via a "trickle-up" effect this implies compatiblility of the two types of function- pointer argument to qsort(). However, I recommend coding the function according to the correct interface specification and using casts within the function to adapt it to the actual situation.