ok, what's the official take on "endianness"?

David Daney ddaney at avtrex.com
Thu Jun 1 18:47:39 UTC 2006


Robert P. J. Day wrote:
>   probably a silly question, but what's the whole story on best
> practises for dealing with endianness?
> 

Is this a trick question?

In general don't write code that has endianness dependencies.

For network code use htonl(), htons(), ntohl() and ntohs().

If you are working with file systems or other things where the 
endianness of on-disk data structures is important, #include <endian.h> 
and be very careful.

David Daney.



More information about the busybox mailing list