Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Structure type comparison Message-ID: <1988Mar6.032131.1177@utzoo.uucp> Organization: U of Toronto Zoology References: <17548@think.UUCP> Date: Sun, 6 Mar 88 03:21:31 GMT > Moreover, two structure, union, or enumeration types declared in > separate translation units are compatible if they have the same number > of members, the same member names, and compatible member types. For two > structures, the members are in the same order. > > I really don't understand these sentences. When is it ever possible for a type > to be declared in one translation unit and compared to a type in another > translation unit without also being declared in the second translation unit? It isn't. The point is that even if the declaration of the type is picked up from a header file, it looks to the compiler like two separate declarations (one in file X and the other in file Y), which normally would not be compatible even if they looked identical. Passing structures (or pointers to them, etc.) from one translation unit to another is proper only if the types *are* compatible, so there has to be an escape clause to make that possible. -- Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry