Casting Function Pointers

Doug Gwyn gwyn at smoke.brl.mil
Fri May 24 06:13:10 AEST 1991


In article <1145 at mwtech.UUCP> martin at 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.



More information about the Comp.std.c mailing list