Jack Klein <> writes:
> On Sat, 26 May 2007 13:37:38 +0200, "Army1987" <>
> wrote in comp.lang.c:
>> "Umesh" <> ha scritto nel messaggio
>> news: oups.com...
[...]
>> > puts("Error opening file");
>> Write that to stderr, not to stdout...
>
> No, no, no, NO, NO!!!
Yes, yes, yes, YES, YES!!!
> The automatic assumption that all programs should write error messages
> to stderr is one of the causes of a lot of grief by inconsiderate
> programmers.
What grief?
> Programs that generate their primary output to stdout might be
> justified in outputting error messages to stderr.
*Might* be?
> Programs that generate their output to a file, as this one attempts to
> do, should indeed generate their error messages to stdout. And that
> specifically includes compilers.
I disagree (as you've probably guessed by now).
Displaying error messages is exactly what stderr is for. I fail to
see the point of writing them to stdout just because a program's
primary output happens to go to a file.
I've just tried 4 different Unix-based C compilers, and they all write
their error messages to stderr. Why exactly is this a problem? (Note
that if they were changed to write error messages to stdout, I know of
some tools that would break.)
I'm assuming here that your environment lets you manage stdout and
stderr reasonably, for example directing them both to the same
destination. If not, that's a problem with your environment, not with
the compiler.
I suppose this discussion of compiler behavior is strictly off-topic,
since a C compiler needn't be written in C, and may not even have the
concepts of stdout and stderr. But the discussion started with an
ordinary C program writing an error message to stderr, and the same
considerations apply.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"