Skip to content

Instantly share code, notes, and snippets.

View stoffera's full-sized avatar

Kristoffer Andersen stoffera

  • Phase One
  • Copenhagen
View GitHub Profile
@jtbr
jtbr / endianness.h
Last active February 13, 2024 08:36
cross-platform / cross-compiler standalone endianness conversion
/**
* @file endianness.h
* @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS
*
* Defines (without pulling in platform-specific network include headers):
* bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64
*
* Should support linux / macos / solaris / windows.
* Supports GCC (on any platform, including embedded), MSVC2015, and clang,
* and should support intel, solaris, and ibm compilers as well.