Is there any “standard” htonl-like function for 64 bits integers in C++?

#define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)) #define ntohll(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)) The test (1==htonl(1)) simply determines (at runtime sadly) if the hardware architecture requires byte swapping. There aren’t any portable ways to determine at compile-time what … Read more