[Lazarus] C Integer types

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Jul 9 03:19:22 CEST 2012


waldo kitty schrieb:

>> 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...

When you declare the record properly:

   TDataHeader = record
     sequence_crc_Ptr,
     sequence_key_Ptr,
     compr_crc_Ptr: PInt64;
     compr_len_Ptr: PLongInt;
   end;

then its size depends on the size of an pointer. In 32 bit code the 
record size will be 16 bytes, in 64 bit code 32 bytes. But since the 
incoming data array has a fixed alignment, more wizardry is required to 
match precisely that layout in OPL.

DoDi





More information about the Lazarus mailing list