Article View: comp.std.c
Article #215Re: const T **
From: John F. Woods
Date: Tue, 14 Apr 1992 21:09
Date: Tue, 14 Apr 1992 21:09
34 lines
1470 bytes
1470 bytes
donne@imec.be (Werner Donne) writes:
>int
>main(void)
>{
> const char **a;
> char **b;
> a = b;
> return 0;
>}
>Why is the assignment illegal?
Because. :-)
'a' is a pointer to 'const char *', and 'b' is a pointer to 'char *', and
these are not compatible types. If the declarations were
char * const * a;
char * * b;
then the assignment would be legal, because assignment of pointers is allowed
to add type qualifiers at the level immediately pointed to:
"both operands are pointers to qualified or unqualified versions of
compatible types, and the type pointed to by the left has all the
qualifiers of the type pointed to by the right."
Unfortunately, only one level of addition is permitted for assignment, which
is kind of a wart, since it certainly seems to make sense to be able to
assign a pointer-to-pointer-to-char into a pointer-to-pointer-to-constant-char.
I don't know why the C Standard Committee only specified one level. And all
of the members of the committee who used to post here seem to have been chased
off, so I guess we'll never know.
Technical Details
Message-ID:
<11434@ksr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!pacbell.com!iggy.GW.Vitalink.COM!widener!eff!world!ksr!jfwReferences:
<1611@imec.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!pacbell.com!iggy.GW.Vitalink.COM!widener!eff!world!ksr!jfw From: jfw@ksr.com (John F. Woods) Newsgroups: comp.std.c Subject: Re: const T ** Keywords: const Message-ID: <11434@ksr.com> Date: 14 Apr 92 17:09:14 EDT References: <1611@imec.UUCP> Sender: news@ksr.com Lines: 34