Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: structure element offsets Message-ID: <7377@utzoo.UUCP> Date: Thu, 4-Dec-86 13:51:58 EST Article-I.D.: utzoo.7377 Posted: Thu Dec 4 13:51:58 1986 Date-Received: Thu, 4-Dec-86 13:51:58 EST References: <1096@spice.cs.cmu.edu> Organization: U of Toronto Zoology Lines: 24 Keywords: structure, offset > ...In other words a cast such as (type1 *)(type2 *)x > will not always give a meaningful answer... True. > According to K&R all > that is required is that (type *)(long *)x == x. False. Please cite chapter and verse. I believe what you are thinking of is (type *)(char *)x == x, which is (by K&R) valid. Your example falls down if, for example, "type" is "char" and the format of "long *" is not precise enough to point to an individual char within a long. Or perhaps you were thinking of (type *)(long)x == x ? That would make me nervous but it is technically valid. > ... for good or ill, > C has been defined such that all members-of-structures share the > same name-space... Not modern C, which puts each structure's members in a separate name space. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,decvax,pyramid}!utzoo!henry