__bswap_16 in /usr/include/bits/byteswap.h has this: __v = __bswap_constant_16 (__x); Which should be this: __v = (unsigned short) __bswap_constant_16 (__x);