Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!xanth!mcnc!rti!xyzzy!agarn!throopw From: throopw@agarn.dg.com (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: Recursive #includes Keywords: recursive includes, modularity Message-ID: <3851@xyzzy.UUCP> Date: 7 Mar 89 20:21:00 GMT References: <570@marob.MASA.COM> <9727@smoke.BRL.MIL> <964@philmds.UUCP> <3804@xyzzy.UUCP> <7488@june.cs.washington.edu> <11959@haddock.ima.isc.com> Sender: usenet@xyzzy.UUCP Lines: 31 > karl@haddock.ima.isc.com (Karl Heuer) >> ka@june.cs.washington.edu (Kenneth Almquist) >>I've been told that incomplete types cannot be used in function >>prototypes. For example, >> void f(struct s *); >> struct s { ... }; >> void f(struct s *p) { ... } >>is illegal ... > Yes it is illegal, but due to a scoping problem, not a restriction against > incomplete types. Adding the empty declaration `struct s;' at the top should > cause it to become legal. (I just tested this with gcc.) Testing it with DG C, this amusing, almost inscrutable, (though in spirit quite correct) error message resulted: You have already declared "f" as a variable, enumeration, or typedef in the current block with different type attributes. The following are the previous and current types: Previous type: void (struct s *) Current type: void (struct s *) Note, however, that incompleted types can still be used to break the kinds of cycles I was talking about, since (as Karl points out) this is a scoping problem not encountered in derivatives of the example I gave. -- "Is it an infinite loop?" "I dunno... it sure is *persistent*, anyhow." --- unknown -- Wayne Throop !mcnc!rti!xyzzy!throopw