Volatile binding for const?

Henry Spencer henry at utzoo.uucp
Thu Mar 30 07:00:35 AEST 1989


In article <PARDO.89Mar28105228 at uw-june.stars.flab.Fujitsu.JUNET> pardo at uw-june.stars.flab.Fujitsu.JUNET (David Keppel) writes:
>	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?

Yes.  "char const" in the first declaration is exactly the same as
"const char" -- the "const" is part of the 'basic' type, not the
declarators for the individual variables.  In the second one, the
"const" is part of the declarator.  The first one declares "s" to
be pointer to const char.  The second one declares "s" to be const
pointer to char.  (Both declare "t" to be pointer to const char.)
There are two places where "const" may appear -- as part of the
'basic' type, and as part of a declarator (AFTER the "*"), and the
meanings are different.

Few will dispute that the syntax is revolting, even for C.
-- 
Welcome to Mars!  Your         |     Henry Spencer at U of Toronto Zoology
passport and visa, comrade?    | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list