[fpc-pascal] Binary compatibility between Intel CPU and PowerPC CPU

Gustavo Enrique Jimenez gejimenez at gmail.com
Wed Sep 17 02:52:24 CEST 2008

2008/9/16 Adriaan van Os <fpc at microbizz.nl>:
> Roland Turcan wrote:
>> Hello FPC-Pascal users discussions!
>> What is the best way to keep the binary compatibility among different
>> CPU architectures.
>> I need to make our own database engine compatible and other binary
>> files, that user still can use our data from i386 or PowerPC computer.
>> I really don't like the idea to change the order of all numeric
>> variables on PowerPC, because it costs time of CPU.
>> There must be easier way how to keep the compatibility.
>> Could you give me some hints for better solution.
> Whether you "like the idea" or not, the best way is as follows:
> - add a byte to the header of source data that indicates the endianness,
> high-endian for PowerPC, low-endian for i386
> - perform byte swapping if the endianness of source data is different from
> the endianness of the current CPU
> With "source data" I mean
> - reading files
> - reading data over a network
> This is best built-into a streaming toolbox, so that it happens
> automatically.
> Adriaan van Os

Don't forget to use packed records (see the Free Pascal Language
Reference Guide). I've used binary files in that way across linux and
windows machines (x86).


More information about the fpc-pascal mailing list