True. But you might consider using inttypes.h which defines some pretty useful things like uint32_t (an unsigned 32 bit wide integer for example).
- "may be a little faster on little-endian machines, but not much, and it's slower on big-endian machines."
In fact swapping the byte order is _one_ CPU instruction. You can for example use some inline assembly to optimize your code. (If your compiler fails to recognize this pattern.)
uint32_t byte_swap( uint32_t x )
{
asm( "bswap %0"
: "=g"(x)
: "0"(x)
);
return x;
}
Just my two cents...