Portability vs. Endianness

John F. Woods jfw at ksr.com
Thu Mar 14 05:41:55 AEST 1991


jfw at ksr.com (John F. Woods) writes:
>[One more time, this time with an open copy of ANSI C]
Now, opening the FIRST chapter, ...

>Further hmm.  Is memcpy() obliged to do anything sensible if handed
>a pointer to an integer cast to a void *?

Yes.  Courtesy of section 1.6 and explained by some handwaving in the
Rationale, all C objects can be addressed as arrays of characters.
Of course, on a 1s-complement machine, the characters you find in a long
will NOT be the same characters you would find on a 2s-complement machine,
so as long as the declaration of 'var' in the original stays just 'long',
then memcpy() isn't the right answer.



More information about the Comp.lang.c mailing list