Hi Saifi ,
i am not very sure of the answer , but the man page for offsetof states that
:
* This macro is useful because the sizes of the fields that compose a
structure can vary across implementations, and compilers may
insert
different numbers of padding bytes between fields. Consequently,
an
element's offset is not necessarily given by the sum of the sizes
of
the previous elements.
*so the to values might be different because of the padding bits !
hoe this helps,
Thanks
Satish
On Sun, Jul 20, 2008 at 5:29 PM, Saifi Khan <[EMAIL PROTECTED]>
wrote:
> Hi all:
>
> Please forgive me, if this sounds like a basic question.
>
> Consider this simple C struct
>
> struct sample
> {
> int *p;
> char c;
> ...
> char last;
> }
>
> In what scenarios,
> sizeof(struct sample) != offsetof(struct sample, last)
>
> Thanks in advance.
>
> thanks
> Saifi.
>