|
|
|
|
|
by CoolGuySteve
2374 days ago
|
|
No, not really. #pragma pack and/or __attribute__((packed)) have been supported for eons now and guarantee the alignment of struct members between compilers. In newer C++ specs, you can also static assert that the struct is a POD type to statically ensure that there's no accidental vtable pointer. This argument pops up every time someone mentions this and every time it's completely uninformed. |
|
Explicit alignment doesn't suffer from this problem nearly as badly (yeah, you might have to add some padding but that's hardly the end of the world -- and if you have explicit padding fields you can reuse them in the future).