If you really want a data structure which is independent of processor
architecture and compilers why not byte encode the numbers into what
would be described in Pascal as a Packed Array of Char. Then byte
ordering, word alignment etc are irrelevant.
It does require that the client have a function which transforms and
recovers the numbers to the particular format needed by the client
processor/compiler combination but has the advantage that the data may
be shared by Big Endian/Little Endian/RISC and CISC machines.
The extreme case would be to store the numbers as ASCII decimal strings,
rather inefficient but a common way of storing numeric data when it must
be broadly accessable.
JS
Jay Sprenkle wrote:
On 12/8/05, Allan Wind <[EMAIL PROTECTED]> wrote:
On 2005-12-08T10:37:36-0800, Wilson Yeung wrote:
You're expected to cast your structure into an unsigned char *,
because in C/C++, the only portable way to represent a byte is with a
char/unsigned char.
Off-topic, I suppose, but what is a portable representation of a byte?
What does unsigned char pointer give you that a void pointer does not
(other than support for legacy compilers)?
This shouldn't work on your compiler:
void* p;
sizeof(*p)
This should return 1:
unsigned char* p;
sizeof(*p)