This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Precompiler headers


Alexandre Oliva wrote:
> 
> On Jan 13, 2000, Wolfgang Bangerth <Wolfgang.Bangerth@IWR.Uni-Heidelberg.De> wrote:
> 
> > Often many template classes are used, heavy use of STL, operator
> > overloading, many inline functions, etc. As opposed to most projects
> > coded in C, there is actually a lot of code in the headers, not only
> > declarations, and the time needed for I/O is not dominant over
> > processing.

Another similar thing which would be really nice for C++ users that have
header files with a lot of templated and/or inlined code would be for
the compiler to do a more detailed depandency analyses based on the
individual symbols used insead of just header files like Make does.  For
example:

header.hh:
  class C {
    int a_, b_;
  public:
    int a() {return a_+1;}
    int b() {return b_+1;}
  };

a.cc:
  ... do something invloving C::a() but not C::b()
  
b.cc:
  ... do something invloving C::b() but not C::a()

Now if C::b() defination changed in header.hh to say 
    int b() {return b_+2;}

Only b.cc would need to be recompiled as only C::b() changed.  However
with a normal make system both a.cc and b.cc would be recompiled.

This will not require any changes in make becuase gcc can just quite
earrly if it determines that the source file doesn't need to be
recompiled.

Even better have a special .o file for each header file which will
contain all inline function definations for that header file.  This way
changing the defination of either a() or b() will not force a recompile
of a.cc or b.cc unless optimizations are used, as the code to call a()
and b() are just function calls with out optimization, and thus nothing
has changed.

This however would probably require a more suffocated make system as the
special .o files need to be linked in at some point.

-- 
Kevin Atkinson
kevinatk@home.com
http://metalab.unc.edu/kevina/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]