Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.std.c Subject: Re: Volatile binding for const? Message-ID: <9943@smoke.BRL.MIL> Date: 29 Mar 89 16:06:15 GMT References: Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article pardo@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'.