This is the mail archive of the
mailing list for the GCC project.
Re: reduce compilation times?
- From: Tom St Denis <tstdenis at ellipticsemi dot com>
- To: Duft Markus <Markus dot Duft at salomon dot at>
- Cc: Fabian Cenedese <Cenedese at indel dot ch>, gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Nov 2007 08:25:56 -0500
- Subject: Re: reduce compilation times?
- References: <18597F2B47F1394A9B309945EC72411201344D39@servex01.wamas.com>
Duft Markus wrote:
Hi!This is where automated tools come in handy. In my projects, I have
scripts that pick up source files and insert them into the makefile(s).
So with very little fuss I can add new files (either new functionality
or new split up code).
Fabian Cenedese <> wrote:
The problem may not be the .cpp but the .h files. If I add a new
Splitting C files is different to splitting C++ files or splittingIn the case of C++, you can just put each method of a class in a
Java files, Fortran, Ada, ObjC, ....
separate .C file. Provided they all include a .H file which defines
the class prototype it's ok.
or method all files of this class need to be rebuilt. With the
independent functions in C this may be easier to do. But still, if
everything is rebuilt then it doesn't matter how many files you
spread your code over.
Of course from maintenance point of view splitting files is good
I maybe wouldn't go down to function level, more like class level.
Otherwise the bad overview in the file is just transferred to the
+1 ;o) Exactly how i think about it. I personally have a project with
approximately 30K lines, where each .cpp file contains exactly one class
(and it's internal-only stuff...). The project is perfectly
maintainable, further splitting into more files would only make it more
*unmaintainable*, since i would spend my time searching things... ;o)
It really depends on the size of the class whether factoring makes sense
or not. but if you have heaps of 3000+ line long functions, I suspect
you spend enough time searching through them as is.
When I was working on DB2 and scouring their often 6000+ line files
looking for why GCC 4.whatever.beta wasn't working as hot as it could,
it wasn't exactly a lot of fun.
BTW: has gcc a mechanism to determine, wether a change in a header fileCan't a makefile do that?
affects a particular .cpp file? Microsoft has... They skip every file
where no affecting changes are detected...
file.o: file.H file.C
Yes that works fine with GNU Make
make: `ctmp1.o' is up to date.
-bash-3.1$ touch ctmp.H
g++ -c -o ctmp1.o ctmp1.C
-bash-3.1$ cat Makefile
ctmp1.o: ctmp.H ctmp1.C
It's almost like, if you engineer your builds correctly, these are
I don't want to make this personal, but honestly, if you're going to try
and give out advice, at least know what you are talking about. There
are actual proper ways to do things that reduce errors, increase
productivity, etc, etc.