query reg. gcc

Deepak Soi sdeepak@cadence.com
Wed Dec 22 15:42:00 GMT 2004


Hi,
    I have a query regarding the use of gnu compiler gcc . When i 
compile 50  files of a project (.cpp and .c ) using makefile utility 
sequentially , it will take around 75 secs, as noted by "time" command. 
But when i make a single compilation unit of all, it takes just 3 secs 
to compile.By single compilation unit , i mean i create another file 
my.cpp and I  #include all the .cpp files into it. then the compilation 
is showing this much reduction in our project's case.
Surely this difference is due to the time involved due to loading of 
same header files again and again when it is #included in more than 1 
.cpp file So in latter case, each header file will be loaded once, but 
in former case, it will be loaded again and again for each .cpp file, 
hence causing the time problem.
                                                       So my question is 
, Can we set some option in the gcc for a particular project, so that if 
once that header has been loaded or its path has been searched, its path 
been stored somewhere(ahshtable of paths) so that  it can used for other 
files of the project and reduce loading time ,hence reducing the overall 
compile time or rather can we maintain a cache of all the header filles 
so that again reloading is not required. I know about pre-compiling the 
headers, but anything else than that which is possible,will be great????
                           If you can guide some thing on this regard, 
it will be really nice.

thanks
Deepak Soi



More information about the Gcc mailing list