On 06/17/2013 12:41 PM, Daryle Walker wrote:
I've never done this before, so I'm asking first: how do I specify that a struct/class should have no padding at all, at the start, end, or middle? My classes have internal arrays, and specifying no padding lets users use an array of classX<T> as an array of T (just like C++11 std::complex). Complier-specific answers are OK, as long as I can use preprocessor flags to isolate them.
I have a preprocessor flag that's currently set to 0 to indicate that there's no packing. I'll change it to 1 whenever I get a compiler's packing support.
This will always be compiler-specific. For gcc, try the __attribute__((packed)) directive, documented here: http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html Jason