[fpc-devel] Packed record integers and x86_86

J. Gareth Moreton gareth at moreton-family.com
Thu Mar 28 14:59:39 CET 2019

 Heh, much better - thank you!

 On Thu 28/03/19 14:31 , "Karoly Balogh (Charlie/SGR)"
charlie at scenergy.dfmk.hu sent:

 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.) 


 fpc-devel maillist - fpc-devel at lists.freepascal.org [1]


[1] mailto:fpc-devel at lists.freepascal.org
[2] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190328/4ebfb107/attachment.html>

More information about the fpc-devel mailing list