[fpc-pascal] Typed file problem.

Inpromptu inpromptu at operamail.com
Wed Jun 22 23:32:03 CEST 2005

> First of all, Lazarus and GUI/non-GUI difference has nothing to do 
> here. Lazarus allows you to compile non-GUI programs without any 
> problems, if you want. Of course, the same compiler and the same 
> RTL is used to compile GUI (i.e. LCL) and console programs.

Ok ! 

> As far as I understand, by "typed file" you mean that you use file 
> variable of type like "file of TSomeType". This is not any magic 
> format for a file, it just reads/writes a series of TSomeType 
> values from/to a file.


> Are you sure that exactly the same definition of TSomeType is used 
> when you compile GUI and console version of your program ? Maybe 
> some structures are aligned differently when you compile GUI and 
> console version of your program ? Are you sure that the unit where 
> TSomeType type is declared is always compiled in the same FPC $mode 
> ? Maybe you use "string" inside your TSomeType and sometimes it's 
> understood as "ShortString" and sometimes as "AnsiString" ?

This seems to be the problem. Is there any way to stop the compilation of the non-delphi part, to avoid string problem ? Is there anyway to force ShortStrings in the console app ?.

> The one thing that you can check is to print SizeOf(TSomeType) from 
> your program, once from the GUI version and then from the console 
> version. They should be equal. If they are not, you know where your 
> bug is. You must ensure that your units are always compiled with 
> the same options, both for console and for GUI version.
> Otherwise, I think that we could help more if you would show some 
> code snippets how exactly do you read/write your file.
> Michalis
 I will write some simple code...

Thanks !!


Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com

More information about the fpc-pascal mailing list