I\'m finding I\'m spending a lot of time trying to determine member offsets of structures while debugging. I was wondering if there was a quick way to determine the offset
This should do:
#define OFFSETOF(T, m) \ (size_t) (((char *) &(((T*) NULL)->m)) - ((char *) ((T*) NULL)))
Call it like this:
size_t off = OFFSETOF(struct s, c);