Structure type comparison

Henry Spencer henry at utzoo.uucp
Sun Mar 6 13:21:31 AEST 1988


> 	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



More information about the Comp.lang.c mailing list