Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: Multiple typedefs Keywords: typedefs, includes, defines Message-ID: <12955@haddock.ima.isc.com> Date: 3 May 89 22:09:19 GMT References: <2322@lethe.UUCP> <10167@smoke.BRL.MIL> <2402@lethe.UUCP> <10190@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 22 In article <10190@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <2402@lethe.UUCP> dave@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@haddock.isc.com), The Walking Lint