Hi,
On Wed, 18 May 2005 04:55:02 -0400, "Binand Sethumadhavan"
<binand@xxxxxxxxx> said:
On 18/05/05, Mohammed Riyaz <p_mdriyaz@xxxxxxxxxxx> wrote:
Yeah i understand that, but i dont understand the #define statement
syntax wise. like what is (char *)&((type *)0)->mem. and how does it
work?
#define offsetof(type, mem) ((size_t) \
((char *)&((type *)0)->mem - (char *)(type *)0))
You could very well have written the above macro as:
size_t offset = fubar->member - fubar; /* disregarding all the casts */
and gotten the same result.
((type *)0)->mem - (type *)0;