This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Wshadow Problem


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]