[comp.lang.fortran] Compiler messages and exit codes

bernhold@red8 (David E. Bernholdt) (05/23/91)

In article <1991May22.124219.28296@eagle.lerc.nasa.gov> fsset@bach.lerc.nasa.gov (Scott E. Townsend) writes:
>As long as you're on a UNIX-like system, and the errors get routed to
>stdout try something like this:
>
>        f77 flags files whatever | \
>        sed -e "/spurious-message-1-text/d" \
>	    -e "/spurious-message-2-text/d"
>
>I'm no FORTRAN guru, but this technique works great for lint & similar
>programs which don't allow you to turn off 'spurious' messages.

On many compilers, warning messages are sent to stderr rather than
stdout, so you may have to change the `|' following f77 to `|&' in csh
or `2>&1 |' (I think) in Bourne shell (sh).  In fact, using the
changes I just mentioned will handle either case -- where messages are
sent to stderr or stdout because my change simply routes _both_
streams through the sed command.

>Of course this does nothing for the compiler's exit status, a bother if you're
>in a makefile.

Scott's technique could be used to filter _any_ messages from the
compiler, but I doubt if you'd want to apply it to _error_ (as opposed
to warning or informational, etc.) messages -- an error condition
being (by my definition) one which causes the compilation to abort. I
would think one normally would want to see error messages.

I don't think I've met a unix system yet where messages at a level of
_warning_ or below make the compiler exit with an error condition.  In
unix, make will abort on an non-zero exit code (unless explicitly told
to ignore the exit code).  I would be quite upset if a _warning_
caused my make to fail; and, as I said, I have never encountered such
a case.  If it did happen, it would cripple make.

NB, The messages referred to by the original posting in this thread
were _warnings_, not errors.  In other words, they are at the same
level as very common messages such as a variable being declared but
never referenced.  They do _not_ cause the compilation to abort.
-- 
David Bernholdt			bernhold@qtp.ufl.edu
Quantum Theory Project		bernhold@ufpine.bitnet
University of Florida
Gainesville, FL  32611		904/392 6365