🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3067

Re: Casting Function Pointers

#3067
From: Doug Gwyn
Date: Thu, 23 May 1991 20:13
16 lines
1242 bytes
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.
Technical Details
Message-ID: <16248@smoke.brl.mil>
Path: arc1-ca.pugleaf.net!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
References: <1145@mwtech.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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