char* vs void* (was: Comparison functions for qsort() and bsearch())
Henry Spencer
henry at zoo.toronto.edu
Sun Dec 30 10:40:19 AEST 1990
In article <17590 at paperboy.OSF.ORG> dbrooks at osf.org (David Brooks) writes:
>>The ANSI C standard requires that |char *| and |void *| have identical
>>representations...
>
>Do you mean "can both be converted to the same integer type and back
>without loss of information?" Do you mean "can be converted to each
>other and back without loss of information?"
He means "if you take any `char *' and convert it to a `void *', or vice
versa, and then inspect the bits of both in memory, they must be identical".
The intent is specifically that code expecting one can be handed the other,
across an interface without complete type-checking (e.g. a function call
without a prototype in scope), and everything will still work fine provided
that other constraints of the code are satisfied.
--
"The average pointer, statistically, |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list