Hello everyone
When I 'call' offsetof(3) from <stddef.h>, I find 'offsetof' is actually a macro.
I expand it with Eclipse (with CDT), the expanded form is:
Code:
((size_t) &((Node *)0)->next)
Wherein, the
Node is a type I defined:
Code:
typedef struct NODE
{
int value;
struct NODE * next;
} Node ;
And I know
size_t is actually
unsigned int in my computer.
So the fully expanded form is:
Code:
( (unsigned int) & ((Node *)0)->next )
We offten evaluate values like " 0x000f & var ", so that we can get the designated bits we want.
But here, the AND opreator seems doesn't work in that way.
And I find my questions:
1. How does it work?
2. On the left side of AND, that is a built-in type. On the right side, what is it?
Thanks!