On Wed, Mar 27, 2019 at 7:47 PM Sven Barth via fpc-devel < fpc-devel@lists.freepascal.org> wrote:
> DJ Coertzen <patrolliekapt...@gmail.com> schrieb am Mi., 27. März 2019, > 18:27: > >> Hi there, >> >> 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. >> >> Example: >> *type* >> * TMyBinaryHeader = packed record* >> * Sender : Cardinal;* >> >> * Target : Cardinal;* >> >> * Reference : Integer; * >> >> * Flags : Word;* >> * CheckByte : Byte;* >> * end;* >> >> 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. >> > > 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. > > Regards, > Sven > >> _______________________________________________ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel Pointer arithmetic: *for Indx := 0 to SizeOf(TTCPPackageHeader) - 1 do Dec(Byte(Pointer(Cardinal(@x) + Indx)^), ARollCount);*
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel