The
offsetof() macro() does exactly this.
#define offsetof(type, mem)
((size_t)((char *)&((type *)0)->mem - (char *)(type *)0))
The
offset of field a in struct mystruct
is
offset_of_a = offsetof(struct mystruct, a)
offset_of_a = offsetof(struct mystruct, a)
No comments:
Post a Comment