<p>Am 03.06.2016 22:08 schrieb "Bo Berglund" <<a href="mailto:bo.berglund@gmail.com">bo.berglund@gmail.com</a>>:<br>
><br>
> I have a class file implementing interfaces for talking to an embedded<br>
> system and I intend to use this class for both Delphi (on Windows) and<br>
> FPC (on ARM Linux)<br>
> One part of this class deals with transfers of binary data to/from the<br>
> embedded system, which is based on a Motorola MCU and is BigEndian.<br>
> When the class is compiled on Windows it needs to swap 2- and 4-byte<br>
> values to correct for endian differences between Intel and Motorola<br>
> CPU:s.<br>
> I have a working code to do this on Windows, but on FPC I would like<br>
> to use the BEToN() and NToBE functions to convert 16 bit words, 32 bit<br>
> integers and 32 bit floats (single prec) as needed.<br>
> I.e. if running in Delphi on Windows use the Swap and Swap4 functions<br>
> but if running on FPC use the BEToN and NToBE.<br>
> I think I have understood that these functions will convert only if<br>
> the current system is using a different endian than specified by the<br>
> call.</p>
<p>FPC's NToBE and BEToN routines indeed only convert if necessary. I don't know about the Delphi's Swap routines, bit alone from the name I'd say that they swap unconditionally (though considering that Delphi runs only on little endian CPUs that provably won't matter).</p>
<p>> I have tried to figure out a set of {$IFDEF } statements but so far<br>
> with no success.</p>
<p>I'd say that "ifdef fpc" should do the job.</p>
<p>Regards,<br>
Sven</p>