Am 04.06.2016 00:40 schrieb "Bo Berglund" <bo.bergl...@gmail.com>: > > On Sat, 4 Jun 2016 00:05:21 +0200, Sven Barth > <pascaldra...@googlemail.com> wrote: > > >FPC's NToBE and BEToN routines indeed only convert if necessary. I don't > >know about the Delphi's Swap routines, but 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). > > > >> I have tried to figure out a set of {$IFDEF } statements but so far > >> with no success. > > > >I'd say that "ifdef fpc" should do the job. > > > Yes, but then I would also need to use the NToBE and BEToN functions > in the FPC code block and my existing code in the D2007 code in order > for it to work when I run on FPC but in Linux on x86... [snip] > What this does is that it checks system endian on program startup > (once) and then uses this flag all through to either convert or not. > Still with my own Swap4() procedure and the built in Swap() function.
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. Regards Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal