Shadow declarations are a major source of misunderstanding and bugs in C or C++ code. C and C++ allow shadow declarations, but this is one of those features that is better not used in production code that needs to be understood and maintained by multiple people.
-Wshadow compiler option to be warned about shadow declarations.
Note that this option is not part of
-Wextra, so you will need to explicitly add this to your build.
You might find that header files you included from external libraries might throw this warning. (I have faced this with the OpenNI library.) In such a case, ignore this warning only for that particular header file inclusion by using diagnostic pragma, as described here .
Tried with: GCC 5.1 and Ubuntu 14.04