[fpc-pascal] Typed file problem.

Michalis Kamburelis michalis at camelot.homedns.org
Thu Jun 23 00:53:29 CEST 2005

Inpromptu wrote:
> I've found the problem... !
> if the record is 
> Myrecord=record
>          MyInteger:integer;
>          Mystring:string;
>          end;
> compiled with c:\lazarus\pp\bin\i386-bin\ppc386 without any other parameter, sizeof(Myrecord.Myinteger) shows 2.
> compiled inside Lazarus sizeof(Myrecord.Myinteger) shows  4 !
> Because of this, Mystring is readed wrong from the file.
> I think this is a trivial problem, but I don't know how to force MyInteger to be 2 bytes long inside and outside Lazarus... Or 4 bytes long ?

Size of Integer depends on FPC $mode used. See 
[http://www.freepascal.org/docs-html/prog/progap4.html]. So you can 
force Integer to be of specific size by making sure that FPC always uses 
the same $mode, whether you compile console version or GUI version from 

Or you can use "SmallInt" or "LongInt" (depending on what you want -- 2 
or 4 bytes ?) to be sure that, regardless of $mode used, your MyInteger 
has always the same size. See 


More information about the fpc-pascal mailing list