Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ames!mailrus!uflorida!gatech!ncsuvx!ece-csc!rss
From: rss@ece-csc.UUCP (ML)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Lattice C 4.0 bugs
Message-ID: <3750@ece-csc.UUCP>
Date: 12 Aug 88 01:30:05 GMT
References: <6627@bloom-beacon.MIT.EDU>
Reply-To: rss@ece-csc.UUCP (ML)
Organization: the loony bin
Lines: 52

In a previous article rlcarr@athena.mit.edu (Rich Carreiro) wrote:
>
>I have the following code:
>#include 
>main()
>{
>  int i;
>  puts("Enter any number to continue:\n");
>  scanf("%d",&i);
>}
>
>When I run it, the "Enter..." message IS NOT PRINTED until I enter a
>number and hit .  Then the message is printed and the program
>ends.  If I use printf(), the problem goes away.  The Lattice tech
>support man says this is not a bug, but is a problem with the C
>language.  I then tried this program under BSD 4.3, on a uVAX, Ultrix
>5.5 on a uVAX, and BSD 4.2 on a Sun 3/160.  It worked properly on all
>three.  So, can anyone explain this "bug" to me?
>Thanks!
>


The "bug" is that "puts" is not flushing the file buffer after writing
the string to it.  As a workaround, put "fflush(stdout);" after the
"puts()" statement.  I agree that this is annoying.  I've noticed this
problem also with "putc/putchar" -- doing a "putchar('\n');" really
should cause the current line to be printed; but it in fact doesn't
seem to.  (This applies only to line buffered streams, i.e., stdout).
"Stderr" should be completely unbuffered, as least to fall in line
with typical Unix implementations, but I've noticed the same problems
with it though.  IMHO, the Lattice tech guy's answer was a cop out.
"Putc()" should flush buffers for line buffered streams when it outputs
a newline char, and commands like "printf" and "puts" should act as if
they functioned by repeated calls to "putc".  I suppose though that I
couldn't accurately say his answer was *wrong*, being in that the stdio
library is simply that -- a library -- and not part of the C language
proper, so you can implement things however you feel (current efforts
by ANSI committee notwithstanding).

Warning:  I'm still using Lattice 3.10 (I'll wait til the next version
comes out before I consider upgrading), so not everything I say may
apply.

A question:
With V4.x, have they fixed the annoying warning message which always
pops up when you use "putchar/putc" with a character constant --
"Warning: constant converted to required type"?  It's very bothersome
seeing perfectly reasonable statements like "putchar('\n')" generate
warning messages.


     Mark Lanzo
     c/o ...!mcnc!ece-csc!rss