Error: shadowing declaration is deprecated
jicman
jic at mail.com
Sun Dec 24 14:54:05 PST 2006
== Quote from Bill Baxter's article
> jicman wrote:
> > Greetings!
> >
> > this code,
> >
> > foreach(char[] u; FPUsers)
> > {
> >
> > }
> >
> > results in,
> >
> > Error: shadowing declaration jic.libs.FPSDK.FindUser.u is
deprecated.
> >
> > Will anyone explain this to me? I tried to do a search on it,
but I couldn't
> > anything related to this. Found other integer arrays, but
nothing about
> > char[]. Any help would be greatly appreciated. Thanks.
> >
> > jos�
> It means you have another variable named 'u' in the same function
> declared somewhere before that foreach loop. The theory is that
many
> times these are bugs, and when they are they can be hard to spot.
> I'm not totally enamored with the feature myself, since I don't
recall
> ever really been bitten by it, but I have happily shadowed
variables in
> the past when it suited me. Especially little dummy
counter/placeholder
> variables like your 'c' above.
> But anyway, that's what the error means. Just rename 'c' to c2 or
cc or d.
> --bb
Ok, I'll buy that, but this is not working either:
char[] u;
foreach(u; FPUsers)
{
}
That should work.
More information about the Digitalmars-d-learn
mailing list