<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 27, 2019 at 7:47 PM Sven Barth via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">DJ Coertzen <<a href="mailto:patrolliekaptein@gmail.com" target="_blank">patrolliekaptein@gmail.com</a>> schrieb am Mi., 27. März 2019, 18:27:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi there,</div><div><br></div><div>I need a solution for a packed record containing 4-byte 32-bit integers and cardinals, and other byte 8 bit and word 16 bit sized variables to overlay over a stream.</div><div><br></div><div>Example:</div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace">type</span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> TMyBinaryHeader = packed record</span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> Sender : Cardinal;</span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> Target : Cardinal;<br></span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> Reference : Integer; <br></span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> Flags : Word;<br></span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace">CheckByte : Byte;</span></b></span></span></b></span></div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace"> end;</span></b></span></div><div><br></div><div>So on 32 bit systems, SizeOf(TMyBinaryHeader) will report 15 bytes. How do I accomplish this on 64 bit platform and avoiding "myprotocollib.pas(x,y) Error: Typecast has different size (4 -> 8) in assignment" without having to port to ugly byte copy operations.</div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Would you show the code at/around the error location, please? I suspect that it isn't the record that's the problem, but how you use it. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
</blockquote></div></div></div>
_______________________________________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" rel="noreferrer" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a></blockquote><div><br></div><div><div>Pointer arithmetic:</div><div><span style="color:rgb(0,0,255)"><b><span style="font-family:monospace,monospace">for Indx := 0 to SizeOf(TTCPPackageHeader) - 1 do Dec(Byte(Pointer(Cardinal(@x) + Indx)^), ARollCount);</span></b></span></div> </div></div></div>