htonl() vs __builtin_bswap32()
问题 __builtin_bswap32() is used to reverse bytes (it's used for littel/big endian issues (from gcc)). htonl() is used to reverse bytes too (conversion from host to network). I checked both functions and they returns the same result. Are there some one who can confirm that both functions do the same thing? (standard refences are appreciated) 回答1: Just look at source code : (example from glib 2.18) #undef htonl #undef ntohl uint32_t htonl (x) uint32_t x; { #if BYTE_ORDER == BIG_ENDIAN return x;