Richard Heathfield <> wrote in message news:<>...
> Steve Zimmerman wrote:
>
> > Kevin Easton wrote:
> >
> >> In comp.lang.c CBFalconer <> wrote:
> >>
> >>>Jonathan Leffler wrote:
> >>>
> >>>>CBFalconer wrote:
> >>>>
> >>>>>Kevin Easton wrote:
> >>>>>
> >>>>>>CBFalconer <> wrote:
> >>>>>>
> >>>>>>>I consider the const in the header to be a mistake. From N869:
> >>>>>>>
> >>>>>>>7.21.2.2 The memmove function
> >>>>>>>
> >>>>>>>Synopsis
> >>>>>>>
> >>>>>>>[#1]
> >>>>>>> #include <string.h>
> >>>>>>> void *memmove(void *s1, const void *s2, size_t n);
> >
> >
> > I believe that the const in the prototype refers to the void
> > pointer, not the value of s2.
>
> I believe that you believe that.
>
>
> > In other words, the pointer will
> > not be altered from type "pointer to void";
>
> Of course it won't. The const doesn't make any difference to the consistency
> of the type.
>
>
> > the value of s2 itself
> > may indeed be altered: not a mistake, my friend.
>
> To what would you alter s2? You can't do pointer arithmetic with it, so all
> you could do is point it to some other object altogether, in which case it
> isn't much use as a parameter any more.
>
> const void *s2 means that s2 points to an unknown object whose value must
> not be changed through this pointer.
It's useful to note that const is, by ancient unfortunate convention,
misplaced. Consider that const void *s2 is equivalent to
void const *s2, and that C declarations should be read backwards,
so this says that s2 is a pointer to a const void.
|