struct alignment C/C++
In c/c++ (I am assuming they are the same in this regard), if I have the following: struct S { T a; . . . } s; Is the following guaranteed to be true? (void*)&s == (void*)&s.a; Or in other words, is there any kind of guarantee that there will be no padding before the first member? In C, yes, they're the same address. Simple, and straightforward. In C++, no, they're not the same address. Base classes can (and I would suspect, do) come before all members, and virtual member functions usually add hidden data to the struct somewhere. Even more confusing, a C++ compiler may also rearrange members