cpp_weekly
cpp_weekly copied to clipboard
[C++ weekly]: My wishlist : packing + endianess
Channel
C++Weekly"
Topics
I'd like to learn about packing and endianess. I'm using these in embedded context, mostly in C, rarely in C++. Usually to fit data in very limited amounts of RAM or Flash; or to transmit data over a link, bus or network. Anyway, I'm doing it the old way, with #prama pack or something. I wonder if there is some other way to do it.
Length
You tell me ... I'd say it will depend on the question "is there some other way to do it ?" I've been surprise to discover that there is an std::something for alignments. I would be surprise if there's nothing for packing and endianess ...
There's Boost.Endian (https://www.boost.org/doc/libs/release/libs/endian/doc/html/endian.html)
and std::endian (https://en.cppreference.com/w/cpp/types/endian).