This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Wshadow Problem
- From: Soubhik <soubhik at noida dot atrenta dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Cc: soubhik at noida dot atrenta dot com
- Date: Wed, 20 Feb 2002 11:31:12 +0530
- Subject: Wshadow Problem
- Organization: Atrenta, India
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.
begin:vcard
n:Bhattacharya;Soubhik
x-mozilla-html:TRUE
org:Atrenta, India.
adr:;;;;;;
version:2.1
email;internet:soubhik@noida.atrenta.com
title:Software Engineer
x-mozilla-cpt:;16192
fn:Soubhik Bhattacharya
end:vcard