adr <[email protected]> wrote:
> On Sun, 15 May 2022, adr wrote:
>
> > What I mean is if we are going to follow C99 in the use of void*,
> > we should allow arithmetic on them.
>
> Let me be clear, I know that C99 requires the pointer to be a
> complete object type to do arithmetic, and I like that, is consistent.
> But then I don't see the point to use void* as a generic pointer.
It allows you pass pointers of any type without requiring casts:
struct foo s[5] = ...
memmove(s, & s[1], 4 * sizeof(struct foo)); // shift down 1
The compiler won't complain because any pointer type can be passed
to a void* parameter. Otherwise you'd need to cast:
memmove((uchar*) s, (uchar*) & s[1], 4 * sizeof(struct foo));
void* has been standard practice (even on Plan 9) for 30+ years.
It's not worth changing it now. :-)
HTH,
Arnold
------------------------------------------
9fans: 9fans
Permalink:
https://9fans.topicbox.com/groups/9fans/Tecaea3b9ec8e7066-Md96cca95ce4773408cff1b24
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription