Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site amdahl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!amdahl!gam From: gam@amdahl.UUCP (Gordon A. Moffett) Newsgroups: net.lang.c Subject: Re: PCC <-> scope rules for "typedef" ?? Message-ID: <676@amdahl.UUCP> Date: Wed, 5-Dec-84 15:13:49 EST Article-I.D.: amdahl.676 Posted: Wed Dec 5 15:13:49 1984 Date-Received: Fri, 7-Dec-84 01:38:30 EST References: <37300004@convex.UUCP> Organization: Amdahl Corp, Sunnyvale CA Lines: 32 > The following small C program (complete with error messages inserted by > "error") illustrates that "typedef" does not obey the scope rules for > declarations in the portable C compiler. K&R says (in paragragh 11.1, > page 206) that "typedef names are in the same class as ordinary identifiers.", > and proceeds to give an example very much like that given below. > Since re-declaring a typedef names fails in PCC, it can't occur in any programs > compiled with PCC. Are there any widely used C compilers which permit > redeclaration of a typedef name? Should new, "standard" C compilers implement > this feature? > > typedef int intType ; > > x(i) > intType i ; > /*###5 [cc] illegal type combination%%%*/ > { char intType ; /* <<<< Can't re-declare 'intType' in a new scope */ > int(j) ; /* looks strange, but means the same as "int j ;" */ > /*###7 [cc] syntax error%%%*/ > /*###7 [cc] warning: old-fashioned initialization: use =%%%*/ > long(intType) ; /* <<<< "extra" parens cause a different problem */ > > ; > } We seek to follow as closely to K&R as possible in our C compiler. We noticed this problem in PCC but implimented typedef as specified in K&R anyway. (Our criteria for compiler accuracy is what K&R says, and not "But it works on a Vax!"). -- Gordon A. Moffett ...!{ihnp4,hplabs,amd,sun}!amdahl!gam 37 22'50" N / 122 59'12" W [ This is just me talking. ]