17.03.2015 14:37, Vlad Khorsun wrote:
>> >think about this simplified record declaration - how will you declare this?
>> >
>> >GenRowsInMessage = record
>> >iValue: Integer;
>> >iValueNull: WordBool;
>> >sValue: SmallInt;
>> >sValueNull: WordBool;
>> >iValue2: Integer;
>> >iValue2Null: WordBool;
>> >end
>     Alignments (offsets) of members within record should be:
>
> member        data type       sizeof datatype         offset
> iValue        Integer         4                       0
> iValueNull    WordBool        2                       4
> sValue        SmallInt        2                       6
> sValueNull    WordBool        2                       8
> iValue2       Integer         4                       12
> iValue2Null   WordBool        2                       16
>
> but only if record is not packed and declared with {$A+}.
>
> Note, iValue2 have offset 12, not 10 !

   With Turbo Delphi 2006 it is true:

Program Al;
{$apptype console}

type
{$A+}
GenRowsInMessage = record
iValue: Integer;
iValueNull: WordBool;
sValue: SmallInt;
sValueNull: WordBool;
iValue2: Integer;
iValue2Null: WordBool;
end;

var
  n: ^GenRowsInMessage;
begin
  n := nil;
  WriteLn('Size of struct = ', sizeof(n^));
  WriteLn('Offset = ', Integer(addr(n^.iValue)));
  WriteLn('Offset = ', Integer(addr(n^.iValueNull)));
  WriteLn('Offset = ', Integer(addr(n^.sValue)));
  WriteLn('Offset = ', Integer(addr(n^.sValueNull)));
  WriteLn('Offset = ', Integer(addr(n^.iValue2)));
  WriteLn('Offset = ', Integer(addr(n^.iValue2Null)));
end.

   Karol should try to run it on his Delphi version.

-- 
   WBR, SD.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to