For example, in the below code scope of local variable num should be only within else but is it a bad practice?
typedef enum
{
FIRST,
SECOND,
THIRD,
} numbers;
void fun(int check, numbers *num)
{
if (check)
{
..........
.......
}
else
{
numbers num;
............
}
}
man gcc
-Wshadow Warn whenever a local variable or type declaration shadows another variable, parameter, type, or class member (in C++), or whenever a built-in function is shadowed. Note that in C++, the compiler warns if a local variable shadows an explicit typedef, but not if it shadows a struct/class/enum.