offsets in structures.
Geoff Kuenning
geoff at desint.UUCP
Tue Oct 16 07:04:22 AEST 1984
> The expression can be made portable, at least under UNIX, by
>having
> extern end;
>somewhere in a header file, and then replacing "0" in the expression by
>"&end". For maximum portability, of course, use a real object of type
>struct foo in the expression.
> Sam Kendall
(What Sam is talking about would then read like this:)
> (char *)(&((struct foo *)&end)->element) - (char *)&end
Good idea, except am not sure &end is the best symbol to use. Is &end
actually guaranteed to refer to a legal address by itself? What about the
other "&e" symbols: etext and edata? Is it legal is we replace "&end" with
"(&end-sizeof (struct foo))"?
--
Geoff Kuenning
First Systems Corporation
...!ihnp4!trwrb!desint!geoff
More information about the Comp.lang.c
mailing list