string is const char [] ?
Joe Buck
jbuck@synopsys.com
Wed Jun 24 10:10:00 GMT 1998
On 23 Jun 1998, Alexandre Oliva wrote:
> >> > char a1[] = "test not const";
>
> >> This line should cause egcs to flag an error.
Kamil Iskra <kamil@dwd.interkom.pl> writes:
> > Excuse me?! I missed the original mail, but do you really suggest that all
> > the programmers should suddenly switch to:
>
> > char a1[]={'t', 'e', 's', 't', ' ', 'n', 'o', 't', ' ', 'c', 'o', 'n',
> > 's', 't', '\0'};
Alexandre Oliva writes:
> How about:
> const char a1[] = "test not const";
Kamil is trying to initialize a char[], so your suggestion is irrelevant.
Programmers must sometimes initialize a writable string, and the standard
way to do this in C is exactly the way you claim is forbidden. This would
need to be documented as a language incompatibility.
I don't believe that you are correct, Alexandre. I think you are
confusing assignment (where there is a conversion) with initialization.
If the standard is unclear, this is a case where the committee should be
asked to produce a clarification.
More information about the Gcc
mailing list