Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!uwm.edu!lll-winken!llnl!ramius.llnl.gov!rjshaw From: rjshaw@ramius.llnl.gov (Robert Shaw) Newsgroups: comp.lang.c Subject: ANSI typedef rules Keywords: typedef Message-ID: <793@llnl.LLNL.GOV> Date: 15 Mar 91 02:34:40 GMT Sender: news@llnl.LLNL.GOV Reply-To: rjshaw@ramius.llnl.gov (Robert Shaw) Organization: Lawrence Livermore National Laboratory Lines: 53 In regards to ANSI C, what (if anything) does the standard say about an identifer that is in the scope of both a typedef and a variable declaration by the same name? For example, gcc 1.37.1 using -ansi -pedantic -W behaves as indicated on the following source (the numbers 0-2 are for reference later): typedef int thing; void f () { thing t1; /** (0) **/ t1 = 1; { int thing; /** (1) compiler not confused yet **/ thing = 0; h(thing); } { thing t2; int thing; thing t3; /** (2) breaks **/ thing = 0; { thing t4; g(t1,t2,t3,t4,thing); } } } What does the standard have to say about all this ? Is the decl at (1) legal ? should (2) be legal and gcc fails to conform ? What about C++ ? same/different rules about this issue ? Thanx ! Rob Shaw, rjshaw@ocfmail.ocf.llnl.gov, (415) 423-3916 =============================================================================== Rob Shaw rjshaw@ocfmail.llnl.gov ===============================================================================