endianness-and-byte-order
Installation
SKILL.md
Endianness and Byte Order
When to use
- Serializing or parsing any wire or file format where multi-byte integers cross a machine boundary: TCP/IP, UDP, CAN-over-ethernet, binary files, firmware images, RPC payloads, protocol headers.
- Writing or reviewing code that uses
htonl/htons/ntohl/ntohs, or that needs 64-bit network-order conversion. - Detecting the host byte order at compile time or at runtime.
- Converting integers to and from raw byte buffers (packing and unpacking fields of a streamed record).
- Reviewing code that
memcpy/fwrites native structs or unions "as-is" onto a stream, or casts a byte pointer touint16_t*/uint32_t*.