[fpc-devel] Packed record integers and x86_86

DJ Coertzen patrolliekaptein at gmail.com
Wed Mar 27 18:57:56 CET 2019


On Wed, Mar 27, 2019 at 7:48 PM Christo Crause <christo.crause at gmail.com>
wrote:

>
>
> On Wed, 27 Mar 2019, 19:27 DJ Coertzen, <patrolliekaptein at gmail.com>
> wrote:
>
>> 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.
>>
>
> Perhaps use size explicit types such as uint32 and int32?
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


I discovered UInt32 in the meanwhile . Thanks. I replied on the wrong
response about pointer arithmetic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190327/c9e5b15b/attachment.html>


More information about the fpc-devel mailing list