void * ?

Wayne Throop throopw at sheol.UUCP
Thu Jan 11 04:15:18 AEST 1990


> From: bobc at attctc.Dallas.TX.US (Bob Calbridge)
> In what instances does one use the cast (void *)?
> This says to me that you have nothing pointing to something.  1/2 :-)

No, it says that you have something pointing to nothing.

Well...   *ACTually* it says you have something pointing to ANYthing.

The keyword "void" was first introduced to indicate that a function had
no return value, as in void foo();, and in this original context it
means, roughly, "nothing".  But X3J11, to avoid coining new keywords to
take care of these cases, recycled the void keyword to mean "an unknown
type" in the type (void *), and to mean "no arguments (as opposed to an
unknown number of arguments)" in the prototype foo(void). 

So, "void" can mean "nothing", "anything" or "zero", depending on context.

(  Note well that (void *) doesn't mean "an unknown type"... the void
   inside there means that.  The whole thing means "pointer to an unknown
   type."  )
--
Wayne Throop <backbone>!mcnc!rti!sheol!throopw or sheol!throopw at rti.rti.org



More information about the Comp.lang.c mailing list