Uses of \\"short\\" ?

Guy Harris guy at sun.uucp
Sun Oct 27 09:15:29 AEST 1985


> It is particularly important when you are sharing data between machines with
> different integer models (ie. little endian vs. big endian). You then want
> "int16" to mean something very specific (16 bits in little endian format).
> I chose little endian because thats what most networks seem to use (as
> opposed to IBM or Motorola CPUs).

Aside from the fact that many networks don't use little-endian format (as
has been pointed out already), it's not appropriate to build data types with
specified byte orders into a programming language.  Many libraries exist
which put objects into a canonical byte order (the "ntoh" and "hton"
routines in 4.2BSD, the Sun XDR library, etc.).  These operations are only
used when data is exported (to a network connection or a file) or imported;
burdening the compiler with these data types, or burdening its object code
with the responsibility of reordering them on each reference, is a mistake.

Besides, there are other issues than just byte order - floating point
format, padding between structure members, etc., etc..  If you want a
language to specify this, consider putting it into something like a remote
procedure call description language, not in a general programming language.

> BTW, can somebody give me the correct address to reach everybody in
> net.lang.c and std.c.

I don't know whether any gateway exists between the ARPANET and "mod.std.c",
but all mail to the INFO-C mailing list should get gatewayed to "net.lang.c".

	Guy Harris



More information about the Comp.lang.c mailing list