Error: shadowing declaration is deprecated

Bill Baxter dnewsgroup at billbaxter.com
Sat Dec 23 22:36:21 PST 2006


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


More information about the Digitalmars-d-learn mailing list