Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!think!husc6!yale!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.lang.c Subject: Re: Why 'struct foo *x' instead of 'foo *x' Message-ID: <878@m3.mfci.UUCP> Date: 28 May 89 19:06:03 GMT References: <26575@watmath.waterloo.edu> <10213@claris.com> <9137@csli.Stanford.EDU> Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 20 In article <9137@csli.Stanford.EDU> jkl@csli.stanford.edu (John Kallen) writes: > >Does anybody know the reason why structs are defined as they are in C? >I.e. why do I have to say "struct foo" instead of just the tag "foo"? I think one reason is that it allows pointers to foo before foo itself is actually defined. For example: struct foo { struct bar *pb; }; struct bar { struct foo *pf; }; If you tried to say "bar *pb;" before bar was defined, you'd get an error. (Note that although C is willing to assume the same machine representation for all structure pointers, this is not true for arbitrary types (e.g., char *, int *, etc.)