Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-01

Flushing files automatically closed on exit

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gregory L Simpson

I do not subscribe to the mailing lists.

Version: 1.0.4 [2000/12/30] for i386

System: Win98 on Celeron 466

I just converted an old utility of mine to compile under Free Pascal. While testing, I found the end of my output file was missing. This seems to be caused by my relying on program exit to close the file, and Free Pascal not doing a flush when it automatically closed it.

I have compiled this program using several other compilers (Turbo (1.0?), UCSD, gpc...) and not had this problem, so I think it is at least an incompatibility with most compilers, if not a bug.

The source for a simple test program is attached.

Greg Simpson

Marco van de Voort
to Gregory L Simpson
Show quoted text 10 lines
I do not subscribe to the mailing lists. Version: 1.0.4 [2000/12/30] for i386 System: Win98 on Celeron 466 I just converted an old utility of mine to compile under Free Pascal. While testing, I found the end of my output file was missing. This seems to be caused by my relying on program exit to close the file, and Free Pascal not doing a flush when it automatically closed it.

FPC doesn't close it, the OS does, and then it doesn't flush buffers in application space.

I have compiled this program using several other compilers (Turbo (1.0?), UCSD, gpc...) and not had this problem, so I think it is at least an incompatibility with most compilers, if not a bug.

Afaik BP7 doesn't?
Anyway, this is bad programming IMHO (and I'm even not that critical).

We have no compability link with GPC and UCSD, only with BP7 (which afaik doesn't), and Delphi. (which I don't know)

Marco van de Voort
to Gregory L Simpson: I do not subscribe to the mailing lists. Version: 1.0.4 [2000/12/30] for i386 System:…
Show quoted text 6 lines
to be caused by my relying on program exit to close the file, and Free Pascal not doing a flush when it automatically closed it. I have compiled this program using several other compilers (Turbo (1.0?), UCSD, gpc...) and not had this problem, so I think it is at least an incompatibility with most compilers, if not a bug.

Whoops, forgot to say that I'll test with BP tonight, and if it allows it, try to see if it can be fixed.

Peter Vreman
Show quoted text 9 lines
> to be caused by my relying on program exit to close the file, and Free > Pascal not doing a flush when it automatically closed it. > > I have compiled this program using several other compilers (Turbo (1.0?), > UCSD, gpc...) and not had this problem, so I think it is at least an > incompatibility with most compilers, if not a bug. Whoops, forgot to say that I'll test with BP tonight, and if it allows it, try to see if it can be fixed.

BP doesn't keep a list of open files. It leaves it up to the OS.

Marco van de Voort
to Peter Vreman
Show quoted text 11 lines
> > to be caused by my relying on program exit to close the file, and Free > > Pascal not doing a flush when it automatically closed it. > > > > I have compiled this program using several other compilers (Turbo (1.0?), > > UCSD, gpc...) and not had this problem, so I think it is at least an > > incompatibility with most compilers, if not a bug. > > Whoops, forgot to say that I'll test with BP tonight, and if it allows it, > try to see if it can be fixed. BP doesn't keep a list of open files. It leaves it up to the OS.

So far for BP. And I assume Delphi doesn't buffer at all (leaves that too to the OS), so there this can't happen at all.