[fpc-pascal] Typed file problem.

Michalis Kamburelis michalis at camelot.homedns.org
Wed Jun 22 22:42:56 CEST 2005


Inpromptu wrote:
> Hi.
> 
> I have developed a console app, wich use a typed file. I use Lazarus to make the GUI, but there is some problem with the typed file generated by the console app. The GUI app does not read the file correctly. Specially with the string vars. 
> 
> Is it a problem with the delphi mode compilation (some diference handling typed files)? How can I do to detect the problem in compilation time?
> 
> My workaround is to compile the console part first, and then  compile the GUI in Lazarus. But I think that there is a better solution. I can't recompile all the software with Lazarus, because I have a lot of cgi apps (no GUI) that reads the typed files.
> 
> Thanks in advance! Lazarus is great !
> 
> Inpromptu. 
> 
> (excuse my english...)
> 

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.

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" ?

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




More information about the fpc-pascal mailing list