Endianness in C++20

A portable way to check for system endianness in C++

CMP
2 min readSep 8, 2023

--

Endianness Basics

The endianness of a system refers to the order in which bytes are stored in memory or transmitted over a network. Big-Endian systems store the Most Significant Byte (MSB) at the lowest memory address. This is used in various network protocols to send data over a network, also known as Network Byte Order. In Little-Endian systems, the Least Significant Byte (LSB) is stored at the lowest memory address. For example, the hexadecimal number 0x12345678 would be stored as…

--

--

CMP

Software engineer specializing in operating systems, navigating the intracicies of the C++ language and systems programming.