[PATCH 2/2] mount: -T OTHERTAB support
Laurent Bercot
ska-dietlibc at skarnet.org
Wed Mar 11 19:00:27 UTC 2015
On 11/03/2015 19:14, Isaac Dunham wrote:
> And second, I'm not really understanding what's constant when I write
> "const char *".
>
> I had thought that it meant that the pointer was immutable, and that
> "char *const STRING" marked the contents of "STRING" as immutable. Is
> that backwards?
Yes.
Not your fault. The C typing system sucks.
Both "*" and "const" are type modifiers, that apply to the type
declared _before them_.
"char const *" is a mutable pointer to an immutable char.
"char *const" is an immutable pointer to a mutable char.
"char const *const *" is an immutable pointer to an immutable char.
Now a huge source of confusion is that "const" can be used as a prefix
modifier too, and not only a postfix one. That's why you see "const char *".
When it's used as a prefix, "const" has priority over all postfix
modifiers. So "const char *" really means "char const *" and not "char *const".
I've always found it easier to stick to the postfix form. That makes the
type system a bit more understandable.
--
Laurent
More information about the busybox
mailing list