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: Precompiled headers and General Parsing of Header File


| > Does egcs allow for precompiling header files?
| 
| I have been meaning to suggest that for a long time.  I am glad you brought it
| up.
[..snip..]

For me, the Bad Thing(tm) about templates is that they need
to be included in a LOT of *different* source.cc files, and
are compiled every time again :(.

What would speed up compilation enormously is when somehow
a headerfile that is included in many different source
files is only compiled once (if possible).

I've been thinking about this for some time (I'm writing
a C++ parser myself, with as main reason that I need
a working indent and want to have something that generates
docs from my source) and I came up with the following idea:

When parsing a header file, a MACRO "signature" of the
headerfile should be constructed: Which macro's are used
in #if, #ifdef and #elif and what are their values at
the entry of the headerfile.  Then, while compiling
source.cc, a header.o "database" should be generated
that includes this signature.  The same header.o then
can be used for other source files when they #include
the header.h with the same macro "signature".

The recursive #includes of headerfiles is something that
makes me uncertain that this can ever work satisfactory
however.

---

There is something else that makes me think however...
It seemed to me that I could accomplish the same
by using -fno-implicit-templates and instantiating
templates only once, in a single source file.
(I automated the generation of the instantiations,
and it worked with gcc-2.7.x.  It does NOT work with
gcc-2.8.x and egcs, and I believe these to be broken).
But, the speed up of this was VERY little. Almost nothing
(maybe 10% faster).
So, perhaps you're right and most of the time is spend
in parsing?.

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>


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