[Lazarus] C Integer types

Marco van de Voort marcov at stack.nl
Sat Jul 7 09:43:43 CEST 2012


In our previous episode, Dave Coventry said:
> 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]);
> 
> Currently, I'm doing it manually, but I'm not getting the results I'm expecting.

This assumes data is a pbyte or pchar (char * or byte *)

then & translates to @, and int64_t* to pint64 the first * changes to ^ at
the end:

   seqence_crc:=pint64(data)^;
   seqence_key:=pint64(@data[8])^;
   compr_crc:=pint64(@data[16])^;
   compr_len:=pint64(@data[24])^;

> I'm pretty sure there is a way of doing this natively, but I can't
> seem to find it.

It's 1:1 translatable. Note the absence of @ and & in the first line though,
that is on purpose. (in both fragments)




More information about the Lazarus mailing list