John Stanton wrote:
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



You are describing here the thing that's called serialization. See one of my previous post in this thread about that. My favorite lib for serialization is boost::serialization allows serialization of c++ objects into binary, text(ascii) or xml strings and more...
for example,
struct intDouble {
  int x;
  int y;
};

would be serialized in xml this way:

<intDouble class_id="0" tracking_level="0" version="0">
        <x>1</x>
        <y>2</y>
</intDouble>

http://www.google.ca/search?q=boost+serialization

Reply via email to