C6244
warning C6244: local declaration of <variable> hides previous declaration at <line> of <file>
This warning indicates that a declaration has the same name as a declaration at an outer scope and hides the previous declaration. You will not be able to refer to the previous declaration from inside the local scope. Any intended use of the previous declaration will end up using the local declaration This warning only identifies a scope overlap and not lifetime overlap.
Example
The following code generates this warning:
#include <stdlib.h>
#pragma warning(push)
// disable warning C4101: unreferenced local variable
#pragma warning(disable: 4101)
int i;
void f();
void (*pf)();
void test()
{
// Hide global int with local function pointer
void (*i)(); //Warning: 6244
// Hide global function pointer with an int
int pf; //Warning: 6244
}
#pragma warning(pop)
To correct this warning, use the following sample code:
#include <stdlib.h>
#pragma warning(push)
// disable warning C4101: unreferenced local variable
#pragma warning(disable: 4101)
int g_i; // modified global variable name
void g_f(); // modified global function name
void (*f_pf)(); // modified global function pointer name
void test()
{
void (*i)();
int pf;
}
#pragma warning(pop)
When dealing with memory allocation, review code to determine whether an allocation was saved in one variable and freed by another variable.