Volatile binding for const?
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Mar 30 02:06:15 AEST 1989
In article <PARDO.89Mar28105228 at uw-june.stars.flab.Fujitsu.JUNET> pardo at uw-june.stars.flab.Fujitsu.JUNET (David Keppel) writes:
>I'm confused about the proper binding for the `const' and `volatile'
>keywords. Both of my `pANS conformant' (:-) compilers tell me
>something about storage qualifiers that I find counter-intuitive.
> char const *s, *t; =is=> {char const *} s, t
> char *const s, *t; =is=> char {const *s}, *t
>The second one makes sense to me. The first one doesn't. Is this
>behavior correct? Is there a rationalle that would help my
>intuition get a little closer to reality?
Perhaps it will help to observe that `s' has a different type in the
two cases. In the first case it is a pointer to a const char, while
in the second case it is a const pointer to a char.
Thus, "const" in the first case applies to "char" in effect, and is
thus part of the types for both `s' and `t'. In the second case,
"const" applies to the "*" associated with `s' but not to the "*"
associated with `t'.
More information about the Comp.std.c
mailing list