Multiple typedefs

Karl Heuer karl at haddock.ima.isc.com
Thu May 4 08:09:19 AEST 1989


In article <10190 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <2402 at lethe.UUCP> dave at lethe.UUCP (Dave Collier-Brown) writes:
>>[why are repeated typedefs illegal?]
>
>Well, consider how the compiler is going to parse a complex declaration
>containing several typedefs.  How does it know whether you are defining the
>same typedef a second time or are just using it to help typedef something
>else?

It seems to me that the compiler is going to have to be able to handle such a
case anyway.  Note that
	typedef int foo;
	void f(void) {
	    typedef int foo;
	}
*is* legal (and would be even if the two types didn't match; the second simply
hides the first until end-of-scope).  At the point of the second declaration,
the compiler has to be prepared for both a redeclaration of foo and a new
declaration using foo.  Given a compiler that can parse this, it would seem
that the extra effort to handle the desired feature would be negligible.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.std.c mailing list