How can I read several hundred lines of C compiler warnings and error messages??

Oh, I'm not asking, how to understand, how to interprete them. I simply would like to see them first of all: When I compile a code of many, many thousand lines and get something wrong, something trivial like e.g. a typo in a variable declaration, a missing semicolon, a bracket I forgot to close, etc., the compiler complains at that offending line (good!)... and then goes on and compiles the rest of my code and vomits hundreds of warnings and error messages all over my screen for every occurence of e.g. the missing variable (very, very bad!). This is supremely annoying and obviously not the least bit helpful, as I'm not interested in all the inherited errors but in the primal error! (It's a bit like that original sin thing ;-)

So I scroll up in my xterm to find the line where this primal error occured. And then I discover, that the buffer of my xterm is simply too small to go back to the very beginning and stops somewhere at line 1768 with complaints about inherited errors. Argh.

Next, I think I'm smart and dump the compiler output into a text file:

make > compileroutput.txt

... and when I look at that file compileroutput.txt I discover that it is almost empty. It doesn't contain the error messages, only a few things which are printed by the makefile.

Hell, why???

The reason is, that make > compileroutput.txt sends everything which goes to STDOUT into the file compileroutput.txt. But the error messages and warnings from the compiler aren't sent to STDOUT but to STDERR!

To dump them into a fle one has to do the following -- and, as always: 103 thanx to Chris who showed me that trick!:

make > output_stdout.txt 2 > output_stderr.txt

The first file will contain only the messages which are sent to STDOUT but the second file will contain all the error messages and warnings from the compiler, sent to STDERR. (Normally both are sent to the screen!).

With less one can have a look at it and identify the source of the problem. (BTW: if you type "/" in less, you can specify a search string and skip with "n" (=next) through every occurence of the search string. Shift+"n" goes back again.)

 

-- Markus Ehrenfried, 2004/08/26