Skip to content

Instantly share code, notes, and snippets.

@embeddedmz
Created February 20, 2020 16:35
Show Gist options
  • Save embeddedmz/3d9ceee9576084cc5634f9a6126fda3c to your computer and use it in GitHub Desktop.
Save embeddedmz/3d9ceee9576084cc5634f9a6126fda3c to your computer and use it in GitHub Desktop.
const uint32_t test = 0xAABBCCDD;
const bool isBigEndian = (*reinterpret_cast<const uint8_t*>(&test) == 0xAA) ? true : false;
if (isBigEndian)
{
std::cout << "CPU is big endian !" << std::endl;
}
else
{
std::cout << "CPU is little endian !" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment