public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Wshadow Problem
@ 2002-02-18 15:23 Soubhik
  0 siblings, 0 replies; only message in thread
From: Soubhik @ 2002-02-18 15:23 UTC (permalink / raw)
  To: GCC-Help List; +Cc: ayan, debasish, soubhik

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

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.

[-- Attachment #2: Card for Soubhik --]
[-- Type: text/x-vcard, Size: 219 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-02-18 17:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-18 15:23 Wshadow Problem Soubhik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).