C portability gotcha, example

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Sat Nov 2 14:03:59 AEST 1985


> One of the fellows here ran across a C coding style problem
> that caused an application to break when ported from little-
> endian machines to a big-endian.  I am posting this to help
> those who may encounter similar problems in the future.

Rwells at BBN-PROPHET.ARPA has pointed out to me that this is not
necessarily a big-endian problem, and that the example would
work on many big-endian systems and may fail on some little-
endians.  It should really be described as a program that
malfunctioned when ported to a machine with *more stringent
alignment constraints*.  Those of you who were puzzled may
find this to be the clue you needed.

(Big-endianness would have to be combined with data addressing
at the high-address byte before it would be the causal factor;
this combination appears to be rarer than I at first believed.)



More information about the Comp.lang.c mailing list