PCC <-> scope rules for "typedef" ??

graham at convex.UUCP graham at convex.UUCP
Tue Dec 4 02:29:00 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 */

  ; 
}



More information about the Comp.lang.c mailing list