Operations on pointers to void.
Colin Plumb
colin at array.UUCP
Sat Aug 11 10:16:23 AEST 1990
In article <1990Aug10.165644.9238 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
> 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.
Exactly. A void * can be assigned, passed, returned, and compared. Period.
> Many compilers, especially old ones with `void *' hastily kludged in,
> treat `void *' much like `char *'. That is a compiler bug.
Actually, gcc documents its permission of pointer arithmetic on void *
as a feature. I disagree. Certainly -ansi -pedantic should complain
about the extension.
--
-Colin
More information about the Comp.lang.c
mailing list