Can gcc show status of a compilation?

Tony Wetmore
Mon Nov 15 09:30:00 GMT 2010

On 11/14/2010 2:04 AM, Greatwolf wrote:
 > Is there any option or switch available that can make gcc display
 > some information to stdout/stderr as it compiles source files?
 > Like for example, in msvc, dmc, borland and other compiles it
 > displays the path/filename of the source being compiled. Is there
 > anyway to do this in gcc?

In my experience, output such as this is generally printed by the 
program that is invoking the compiler, rather than the compiler itself. 
  For example, when using make (or GNU make), it can output the file 
being compiled using directives such as this:

   %.o: %.C
     @echo "    Compiling  $*"
     @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<

That is an excerpt from a Makefile in one of my projects that builds any 
.C file using GCC's C++ compiler, and outputs the name of the file just 
before compiling it.

Again, with most projects of mine, the compiler is generally only asked 
to compile a single file, so having it print out the name of that one 
file would be redundant.  After all, I just told the compiler the name 
of that file, why should it immediately need to print it back to me?

Oh the other hand, if you are using the compiler to build an entire set 
of files at once and want to see its progress, that sort of output may 
be useful.  However, I would recommend that you consider using a tool 
such as make to build your projects.

Using make, you will have finer control over re-compiling only those 
files that have changed, which may greatly reduce your recompilation 
times, and you will have the ability to generate the output you desire.

Hope this helps!


More information about the Gcc-help mailing list