TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DARIN MCBRIDE
from: MATHIEU BOUCHARD
date: 1997-09-10 04:17:00
subject: Why the braces?

 DM> int main(int argc, char**)
 DM> {
 DM>     switch(argc)
 DM>     {
 DM>     case 1:
 DM>         int foo = 1;
 DM>         break;
 DM>     case 2:
 DM>         int foo = 2;
 DM>         break;
 DM>     }
 DM>     return argc;
 DM> }
That's almost exactly the one i used except i didn't even care for
writing return. TCC is a bit old, so it didn't catch the initialization
thing.
 DM> [0] g:\src\z>gcc z.cc -c
 DM> z.cc: In function `int main(int, char **)':
 DM> z.cc:9: jump to case label
 DM> z.cc:7:   crosses initialization of `int foo'
 DM> z.cc:10: redeclaration of `int foo'
 DM> z.cc:7: `int foo' previously declared here
 DM> z.cc:10: warning: unused variable `int foo'
 DM> Here:
 DM>   [0] g:\src\z>gcc -v
 DM>   gcc version 2.7.2.1
Well, i couldn't get anything really different. I use gcc 2.7.2.0.
matju
--- Terminate 4.00/Pro
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.