Wshadow Problem
Soubhik
soubhik@noida.atrenta.com
Mon Feb 18 15:23:00 GMT 2002
Hi!
i've encountered something very funny. 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.
Here's the simple program:
typedef int myint;
extern void foo(myint myint);
Here's c compilation:
#gcc -c -Wshadow typetest.c
typetest.c:3: 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-help/attachments/20020218/fe0eb061/attachment.vcf>
More information about the Gcc-help
mailing list