<p>Am 04.06.2016 00:40 schrieb "Bo Berglund" <<a href="mailto:bo.berglund@gmail.com">bo.berglund@gmail.com</a>>:<br>
><br>
> On Sat, 4 Jun 2016 00:05:21 +0200, Sven Barth<br>
> <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> wrote:<br>
><br>
> >FPC's NToBE and BEToN routines indeed only convert if necessary. I don't<br>
> >know about the Delphi's Swap routines, but alone from the name I'd say that<br>
> >they swap unconditionally (though considering that Delphi runs only on<br>
> >little endian CPUs that provably won't matter).<br>
> ><br>
> >> I have tried to figure out a set of {$IFDEF } statements but so far<br>
> >> with no success.<br>
> ><br>
> >I'd say that "ifdef fpc" should do the job.<br>
> ><br>
> Yes, but then I would also need to use the NToBE and BEToN functions<br>
> in the FPC code block and my existing code in the D2007 code in order<br>
> for it to work when I run on FPC but in Linux on x86...<br>
[snip]<br>
> What this does is that it checks system endian on program startup<br>
> (once) and then uses this flag all through to either convert or not.<br>
> Still with my own Swap4() procedure and the built in Swap() function.</p>
<p>FPC has the defines ENDIAN_LITTLE and ENDIAN_BIG (for Delphi you can implicitly assume that it's little endian, maybe simply define ENDIAN_LITTLE if FPC is not set). It's better to enable/disable the swapping code at compile time so that there is no branch in those routines.</p>
<p>Regards<br>
Sven</p>