HARRIS FLAME Re: SHORT vs. INT

Jeffery A. Cavallaro jeff at ISI-VAXA.ARPA
Tue Sep 10 03:12:00 AEST 1985


What Mr. Harris meant to say (he didn't say it too well) was the following:

"short" and "long" are generic "int" types that should be used whenever
a general purpose integer value is required.  These types are meant to
provide compatability on two levels:

1.  PORTABILITY

The ability to port code between different machine types and operating systems
that support C.

2.  NETWORK COMMUNICATION

To enable network communication between different machines, a "short" is
guaranteed to be 16-bits and a "long" is guaranteed to be 32-bits.  This
is either convention or standard, I am not sure which.  If anyone knows
if this is a printed standard, I would appreciate them sending me a
message with the reference.  When sending data over a network, the
"byteorder(3N)" routines should be used to convert machine-dependant
"short" and "long" types to a network standard byte order.  When receiving
these types, one should convert back to the machine-dependent forms.
By the way:  WHOLE STRUCTURES SHOULD NEVER BE TRANSMITTED OVER A NET DUE
		TO BYTE ORDER AND ALIGNMENT PROBLEMS.

In contrast, the "int" type is a very machine-dependent type.  It is made
equivalent to a machine's natural word size.  This type is needed if C is
going to make any claims about being an "operating system capable" language.

FLAME OF MY OWN:
People such as Mr. Harris should be aware that not all people participating
in this forum are experts.  The question was a valid one, and deserved a
reasonable response, not a better-than-thou dissertation.  Such responses
just intimidate people who might otherwise benefit by asking questions of
this type.

					Jeff



More information about the Comp.lang.c mailing list