Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!unhd!rg From: rg@uunet!unhd (Roger Gonzalez ) Newsgroups: comp.lang.c Subject: structure typedefs Message-ID: <1990Mar28.150755.6803@uunet!unhd> Date: 28 Mar 90 15:07:55 GMT Reply-To: rg@unhd.unh.edu.UUCP (Roger Gonzalez ) Distribution: comp Organization: Marine Systems Engineering Lab Lines: 41 Could someone kindly explain to me the difference between typedef struct foo { typedef struct { .. .. }; and } foo; struct foo bar; foo bar; In some situations, it doesn't make any difference at all. In others, most notably when you have a pointer to the same type (i.e. linked list stuff) typedef struct foo { .. struct foo *next; }; struct foo bar; I seem to recall even seeing this: typedef struct foo { .. struct foo *next; } foo; foo bar; Which looks to me like it should cause an error. Please enlighten me as to the subtleties of this. I'm not a novice C programmer, and I've been using structures for years, and I know how to make them work, but I've never really understood exactly what was going on internally. Email if possible; I don't read this group often. -Roger -- UUCP: ..!uunet!unhd!rg | USPS: Marine Systems Engineering Laboratory BITNET: r_gonzalez at unhh | University of New Hampshire PHONE: (603) 862-4600 | Marine Programs Building FAX: (603) 862-4399 | Durham, NH 03824-3525