Re: reduce compilation times?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2007/11/28, Tom St Denis <tstdenis@xxxxxxxxxxxxxxxx> wrote:
> >> In the case of C++, you can just put each method of a class in a
> >> separate .C file.  Provided they all include a .H file which defines the
> >> class prototype it's ok.
> >>
> >
> > I'm not sure if GCC C++ does it.
> >
> Yes, it does.  Consider:
>
> ctmp1.C
> #include "ctmp.H"
>
> ctmp::ctmp(void)
> {
>    cout << "hello world" << endl;
> }
>
> ctmp2.C
> #include "ctmp.H"
>
> ctmp::~ctmp(void)
> {
>    cout << "goodbye world" << endl;
> }
>
> ctmp.H
> #include <iostream>
> using namespace std;
>
> class ctmp {
>    public:
>       ctmp(void);
>       ~ctmp(void);
> };
>
> Both .C files compile just fine.

Have you problems in separated files in below cases?
A) When they are using "nested" templates.
B) When there are "cyclic" dependences of compilation beetwen 2 or more files.
C) When there are "overloading" of methods and functions, virtual and
non-virtual.
D) When there are macros in C++.
E) When there are __atributes__ in C++.

>
> >> In the case of Java, you can break up a large task into classes which
> >> handle separate functions of the program.  For example, a compiler may
> >> have an I/O class, a lexer class, a parser class, an interface for
> >> optimizations, and various implementations of the interface, etc, etc.
> >> Hell, most colleges teach things like the MVC model when doing GUI Java
> >> apps which, last I checked, is a way to refactor one large program into
> >> separate tasks.
> >>
> >
> > We've talking to split files (e.g. 1 file per 1 function or per 1 method),
> > not to separate tasks or factor tasks.
> >
> > Java can't split many methods of a class to many files,
> > only 1 file per 1 class, not 1 file per method.
> >
>
> Refactoring doesn't strictly mean one function per file.  That's the
> ideal [in most cases].  Refactoring simply means breaking a large task
> into smaller re-useable components.  For example, suppose you had a Java
> program made up of 10 classes, and each class you manually coded up a
> [say] GZIP decompressor, wouldn't it make more sense to split that off
> into it's own class?  That's re-factoring.

I understand it, but GCC compiler doesn't understand the "refactoring" meaning.
GCC only understands the difference between splittled and non-splitted files,
and how to affect him in terms of compile-time and optimization-gainining.

   J.C.Pizarro

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux