PCC <-> scope rules for "typedef" ??
Gordon A. Moffett
gam at amdahl.UUCP
Thu Dec 6 06:13:49 AEST 1984
> 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. ]
More information about the Comp.lang.c
mailing list