[fpc-devel] Packed record integers and x86_86

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Thu Mar 28 15:31:08 CET 2019


Hi,

On Thu, 28 Mar 2019, J. Gareth Moreton wrote:

> I think the official unsigned 32-bit integer type in Pascal is
> "LongWord". As others have said, be aware that pointers are 64-bit under
> x64... that's kind of why it's called x64!  If you absolutely must have
> a packed record with 32-bit types, I recommend changing Sender and
> Target to indices that are added to a base address.
>
> Similar to what Pierre said, change your Pointer code to something like
> this:
>
> for Indx := 0 to SizeOf(TTCPPackageHeader) - 1 do Dec(Byte(Pointer(PtrUInt(@x) + Indx)^), ARollCount);

How about Dec(PByte(@x)[Indx], ARollCount); instead? That doesn't look
like an angry C programmer tried to convert some abomination to Pascal,
and works on all pointer sizes.

(Unless it also has to compile with say, Delphi.)

Charlie


More information about the fpc-devel mailing list