Re: offsetof
- From: junky_fellow@xxxxxxxxxxx
- Date: 30 Sep 2005 03:00:05 -0700
luke wrote:
> hi all,
> i have another question.
> I've read the FAQ regarding my former question (sizeof struct and
> union) and in question 2.14 it talks about offset macro.
>
> #define offsetof(type, mem) ((size_t) \
> ((char *)&((type *)0)->mem - (char *)(type *)0))
>
> Can anyone explain me how it works.
> 1)I can't understand what "0" casted to (type *) means
> 2)Isn't the second menber of substraction "(char *)(type *)0" useless?
The second member of sustraction would be required on implementation
where the NULL pointer is *not* represented by all-bits-zero.
Probably, this is why offsetof macro is implementation specific.
.
- Follow-Ups:
- Re: offsetof
- From: Flash Gordon
- Re: offsetof
- From: Richard Tobin
- Re: offsetof
- References:
- offsetof
- From: luke
- offsetof
- Prev by Date: Universal (g)libc
- Next by Date: Re: Assembler vs Compiler vs Linker
- Previous by thread: offsetof
- Next by thread: Re: offsetof
- Index(es):