[fpc-pascal] FPC Advanced Records

Ludo Brands ludo.brands at free.fr
Sat Mar 10 15:53:25 CET 2012


> >
> > where by the time ThisSize is accessed any disparity has been 
> > corrected?
> >
> 
> Not sure if this will be of any use.
> 
> but you can always define an assignment incompatible type
>     WordLE = record data: Word; end;
> 
> and define all required overloaded operators 

Or an endian independant implementation:

type
  wordLE=packed record
    L1,L2:byte;
  end;

operator := (w1:word) w2:wordLE;
  begin
    w2.L2:=(w1 shr 8) and $FF;
    w2.L1:=w1 and $FF;
  end;

operator := (w1:wordLE) w2:word;
  begin
    w2:=((w1.L2 shl 8) and $FF00 ) or word(w1.L1);
  end;

Ludo




More information about the fpc-pascal mailing list