Operations on pointers to void.

Henry Spencer henry at zoo.toronto.edu
Sat Aug 11 02:56:44 AEST 1990


In article <1990Aug9.231614.5196 at basho.uucp> john at basho.uucp (John Lacey) writes:
>... dereferencing and subscripting are illegal.
>But, what about pointer arithmetic? ...

Subscripting *is* pointer arithmetic.  Apart from passing them around and
comparing them to each other and to NULL, there is *nothing* you can do
with `void *'s except convert them to another kind of pointer.  No
dereferencing, no arithmetic.  They are containers for other kinds of
pointers, not pointers themselves.

Many compilers, especially old ones with `void *' hastily kludged in,
treat `void *' much like `char *'.  That is a compiler bug.
-- 
It is not possible to both understand  | Henry Spencer at U of Toronto Zoology
and appreciate Intel CPUs. -D.Wolfskill|  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list