I\'ve seen a few questions and answers regarding to the endianness of structs, but they were about detecting the endianness of a system, or converting data between the two d
Boost provides endian buffers for this.
For example:
#include #include using namespace boost::endian; struct header { big_int32_buf_t file_code; big_int32_buf_t file_length; little_int32_buf_t version; little_int32_buf_t shape_type; }; BOOST_STATIC_ASSERT(sizeof(h) == 16U);