Portability vs. Endianness, an official answer(?)

Clarence Dold dold at mitisft.Convergent.COM
Fri Mar 15 02:25:13 AEST 1991


in article <Nogsy1w164w at ersys.uucp>, ersys!markt at nro.cs.athabascau.ca (Mark Tarrabain) says:

> this is slightly machine dependant - it assumes that the size of a long

Why not get really machine dependent?  Let the vendor do it for you.

If you have networking, you should have routines to put and fetch
'network byte order' values, BYTEORDER(3N).
There are macros htonl, ntohl, etc, for converting to/from host style to 
network style.

Snoop around for in.h.  On our Motorola box, it is a noop.
On the Intel box, it is some in-line assembly.

(I don't really dispense official answers, but I thought it was a catchy
change to the subject line...)
-- 
---
Clarence A Dold - dold at tsmiti.Convergent.COM
               ...pyramid!ctnews!tsmiti!dold



More information about the Comp.lang.c mailing list