www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/04/01:47:34

Date: Tue, 4 Feb 1997 08:36:56 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Douglas Gleichman <doug AT tcville DOT es DOT hac DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Ghosts in DJGPP :-)
In-Reply-To: <qm3evdah67.fsf@X-147-16-128-32.es.hac.com>
Message-ID: <Pine.SUN.3.91.970204083228.28998K-100000@is>
MIME-Version: 1.0

On 3 Feb 1997, Douglas Gleichman wrote:

> > This doesn't always work because DOS sometimes uses its own buffers for
> > stdout. 
> 
> When?  I've never seen this.

When stdout is redirected to a file or a pipe.

> > fflush() or a newline always works, though.
> 
> Turbo C/ Microsoft C have buffering turned off by default.  DJGPP has
> it on.  The above call to setbuf will make DJGPP operate like those
> other compilers.

But it makes screen I/O much slower, because a mode switch (protected 
mode to real mode and back) is required for *each character* when your 
stream is unbuffered.  That's a lot of overhead if your program has a lot 
to print.

Another ``easy'' solution would be to #define printf cprintf at the top 
of the source code.

> If you are porting a program over to DJGPP it seems
> that it would be a lot easier to add one line than to search for every
> printf and add a fflush after it.

If you indeed care for portability, you should use `fflush' even in Turbo 
C.  If you don't care for portability, then you are amply punished (IMHO).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019