<HTML>
<style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>I think the official unsigned 32-bit integer type in Pascal is "LongWord".<div><br>
</div><div>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.</div><div><br>
</div><div>Similar to what Pierre said, change your Pointer code to something like this:</div><div><br>
</div><div>for Indx := 0 to SizeOf(TTCPPackageHeader) - 1 do Dec(Byte(Pointer(PtrUInt(@x) + Indx)^), ARollCount);<br>
<br>
So similarly with your record, instead of directly derefencing Sender and Target - since I assume your record type must stay fixed at 15 bytes - have something akin to "Pointer(PtrUInt(@BaseAddr) + Sender)".<br>
<br>
The first rule, first and foremost... don't assume the Pointer is a fixed size. Hope all of this helps.<br>
</div><br>
<div>Gareth aka. Kit</div><div><br>
</div><div>P.S. I would recommend adding a "Filler" or "Reserved" byte at the end of your record type to
make it 16 bytes long - such a size is more efficient when it's part of an array in memory.<br>
</div><br>
<br>
<br>
<span style="font-weight: bold;">On Wed 27/03/19 21:11 , Pierre Muller pierre@freepascal.org sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<br>
<span style="color: rgb(102, 102, 102);">> _______________________________________________
</span><br>
<span style="color: rgb(102, 102, 102);">> fpc-devel maillist - fpc-devel@lists.freepascal.org <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>>
</span><br>
<span style="color: rgb(102, 102, 102);">> <a target="_blank" href="<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>"><span style="color: red;">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</span></a>
</span><br>
<span style="color: rgb(102, 102, 102);">>
</span><br>
<span style="color: rgb(102, 102, 102);">>
</span><br>
<span style="color: rgb(102, 102, 102);">> Pointer arithmetic:
</span><br>
<span style="color: rgb(102, 102, 102);">> *for Indx := 0 to SizeOf(TTCPPackageHeader) - 1 do Dec(Byte(Pointer(Cardinal(@x) + Indx)^), ARollCount);*
</span><br>
the error has nothing to do with your record,
<br>
its that part:
<br>
Pointer(Cardinal(@x) + Indx)^)
<br>
<br>
The problem is that Cardinale is an unsigned 32-bit integer,
<br>
while on 64-bit, you will need UINT64,
<br>
<br>
You should use PtrUInt type that is an unsigned type
<br>
that always have the size of an address instead of cardinal here!
<br>
<br>
<br>
Pierre
<br>
_______________________________________________
<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<br>
<a target="_blank" href="<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>"><span style="color: red;">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</span></a>
<br>
<br>
<br>
</blockquote></HTML>