I'm curious how hard it is to implement something like sizeof()?
For example, here's a struct:
typedef struct {
int aa;
float bb;
char cc;
} foo;
sizeof(aa) + sizeof(bb) + sizeof(cc) = 4 + 4 + 1 = 9
sizeof(foo) would yield 12, because the compiler pads the struct
So my question is, how to write a variant of sizeof() that calculates the exact size (non padded) of structures?