[Gc] GC patch for DJGPP
Mon, 3 Nov 2003 14:07:56 +1100
On 02-Nov-2003, Doug Kaufman <firstname.lastname@example.org> wrote:
> On Mon, 3 Nov 2003, Fergus Henderson wrote:
> > On 01-Nov-2003, Doug Kaufman <email@example.com> wrote:
> > > The errno was EACCESS. Adding a call to fflush() seems to fix the
> > > problem. I am not really sure why.
> > ...
> > > if ((f = fopen(FNAME2, "w")) == 0) ABORT("2nd open failed");
> > > + fflush(f);
> > That really ought to be
> > if (fflush(f) == EOF) ABORT("fflush failed");
> But how do you make this compatible across different operating
That code will work on any system which conforms to the ISO C standard
(either the 1990 version or the 1999 version).
> The DJGPP version of fflush returns "0" on success and "-1"
> on failure. I see that Redhat linux, cygwin, and SunOS 4.1 all return
> EOF on failure and "0" on success.
On DJGPP, EOF will be -1, I'm pretty sure. So this code should work
with DJGPP as well as those other systems.
> So you would probably be better off using "if (fflush(f) != 0)".
That would work too.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.