On Sat, Jan 23, 2016 at 04:45:05PM +0100, Didier Kryn wrote:
> Le 23/01/2016 12:16, Didier Kryn a écrit :
> >
> >    I'm curious of the reason why you specify
> >   static void print_start(char const *name, char const *what)
> >
> >    This means the pointers to the arrays of characters are
> >constant (not the characters). The effect of this cannot be to
> >protect the pointers in the caller program since they are passed
> >by value -- copied into register or stack before passing control
> >to the function. If it is for the sanity of the function itself,
> >then congratulations, this is a sane thing to do, even if it is
> >easy to check by eye that the pointers aren't modified. But, to be
> >consistent, since your function doesn't even modify the content of
> >the strings, you should also declare constant the characters
> >themself, like in the following:
> >    static void print_start(const char const *name, const char
> >const *what)
> 
>     Sorry, I overlooked the code and read "char const *name" as if
> it was "char * const name". Actually the syntax you used is
> equivalent to "const char *name". It actually protects the string
> from being overwritten by the function.

I've always said the C syntax for declarators was confusing.
Even those who understand it read it wrong!

(Yes, In understand the logic behind it.  It is still confusing.)

-- hendrik 

_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to