In our previous episode, Bo Berglund said:
> Now, however, the problem may be complicated because the program may
> well run on a CPU that is using the *same* endian structure as the
> original instrument in which case of course the swaps should not be
> done.

Correct.

> So I need some detector or other to decide if swaps are needed.
> Is there some commonly used function to handle this or is there some
> conditional directive one can use to control the compiler to "do the
> right thing" depending on the target CPU endian?

See e.g. the CHM package. It has the same problem, the file structure is
little endian (since windows), but the package may run on e.g. PowerPC.

The routine in the url below is used for that. (in this case ntole, but
ntobe if your storage is bigendian)

http://www.freepascal.org/docs-html/rtl/system/ntole.html
http://www.freepascal.org/docs-html/rtl/system/ntobe.html

These routines are afaik inline and a no-op if the endianness is the same.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to