Share via


PREfast Warning 246 (Windows CE 5.0)

Send Feedback

246 - Local declaration of <variable> hides declaration of same name in outer scope.
Additional Information: See previous declaration at <location>.

This warning indicates that a local declaration has the same name as a declaration at global scope. The name at global scope is hidden by the declaration at scope.

You must understand how the lifetimes of these definitions overlap to determine whether there is a problem with this code. PREfast only identifies a scope overlap.

If the lifetimes of the variables overlap, a problem could exist.

What to look for when investigating this warning:

  • Is the intent a single variable or multiple variables?
  • Is an allocation saved in one variable and freed by the other?
  • Is the correct result being returned?

Example

Defective Source

int Decl1 = 42;

{
    int Decl1;

    Decl1 = rand();
}

return Decl1;

Corrected Source

int Decl1 = 42;

{
    int Decl2;

    Decl2 = rand();
}

return Decl1;

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.