Mail Archives: djgpp/1997/11/14/19:30:23
J P Morris wrote:
>
> Presumably this only happens with UNIX C compilers.
> This never happened with Borland, and it had me confused for a while.
Not quite. While Unix may use buffered output streams, it does _not_
have a conio interface. So there can be no conflict between the two
like there is on DOS. :) Unix may use other types of direct screen
interface; I'm not an expert in those.
Anyway, ANSI makes no guarantees about the buffered status of stdout;
stating only that it can be anything from unbuffered to line-buffered.
Borland, et. al., being 16-bit compilers, can send text directly to DOS
with little overhead, so it makes sense for them to be unbuffered.
DJGPP, however, is a 32-bit compiler, and interfacing with the DOS
filesystem to write out text requires a PM<->RM mode switch, which is
fairly expensive in terms of cycles. So it makes sense to write out
text as seldom as is legal within ANSI.
For a test of what I am saying, find any DJGPP program that produces
voluminous text output, and turn off stdout buffering with setbuf(
stdout, NULL );. The resulting code should run noticeably slower than
before.
hth
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| Descent 2: The Infinite Abyss - The greatest Internet game of all |
| time just got better! This time, you're going all the way down...|
---------------------------------------------------------------------
- Raw text -