Wshadow Problem
Soubhik
soubhik@noida.atrenta.com
Tue Feb 19 23:05:00 GMT 2002
Hi!
it seems that behavior of gcc -Wshadow option is different in c and c++.
i've a very simple program which,
if treated as a c file (extension .c) and compiled with -Wshadow option,
generates a warning. the same program, if treated as a c++ file
(extension .cpp) and compiled with same command options, does not give
any warning. IMHO, the warning genearted in c compilation is
unnecessary.
Here's the simple program:
typedef int myint;
extern void foo(myint myint);
Here's c compilation:
#gcc -c -Wshadow typetest.c
typetest.c:2: warning: declaration of `myint' shadows global declaration
#
And this is c++ compilation:
#gcc -c -Wshadow typetest.cpp
#
gcc version info:
#gcc -v
Reading specs from
/usr/local/gcc/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
#
Finally, this is what the man page of gcc says:
-Wshadow
Warn whenever a local variable shadows another local
variable.
any attempt to get me out of this confusion will be really appreciated.
cheers!
soubhik.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: soubhik.vcf
Type: text/x-vcard
Size: 219 bytes
Desc: Card for Soubhik
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20020219/127ab64b/attachment.vcf>
More information about the Gcc
mailing list