[Lazarus] C Integer types

waldo kitty wkitty42 at windstream.net
Sun Jul 8 20:25:05 CEST 2012

On 7/8/2012 06:32, Bernd wrote:
> 2012/7/7 Marco van de Voort<marcov at stack.nl>:
>>     seqence_crc:=pint64(data)^;
>>     seqence_key:=pint64(@data[8])^;
>>     compr_crc:=pint64(@data[16])^;
>>     compr_len:=pint64(@data[24])^;

the above doesn't seem correct... i've been watching and waiting for someone to 
catch it... i think one did but no one has followed up that...

here is the original from Dave Coventry

 >I have the following C code which I'm trying to emulate in Pascal:
 >  seqence_crc = *((int64_t*)data);
 >  seqence_key = *((int64_t*)&data[8]);
 >  compr_crc   = *((int64_t*)&data[16]);
 >  compr_len   = *((int32_t*)&data[24]);

i see three int64's and one int32... it looks like marco's pint64 on the last 
line is incorrect and that maybe it should be pint32... this was actually asked 
about and it was noted that google was returning results for 32 pints of beer or 

> How about defining something more pascalish first, a record type for example:

i would agree with this since it is more readable ;)

> {$modeswitch autoderef}
> type
>    PDataHeader = ^TDataHeader;
>    TDataHeader = record
>      sequence_crc: QWord;
>      sequence_key: QWord;
>      compr_crc: QWord;
>      compr_len: DWord;
>    end;

and it looks like here you did see and allow for 64bit on the first three and 
32bit on the last one...

> var
>    Data: PDataHeader;
>    SeqCrc: QWord;
>    SeqKey: QWord;
>    ...

and as long as CompLen is a DWORD, this should work... i think? or am i missing 
something on the higher up pint64 stuff??

More information about the Lazarus mailing list