structure element offsets
Henry Spencer
henry at utzoo.UUCP
Fri Dec 5 04:51:58 AEST 1986
> ...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
More information about the Comp.lang.c
mailing list