Board index » cppbuilder » How to compile an entire header?

How to compile an entire header?


2003-08-20 04:34:57 PM
cppbuilder70
Several times I have had my .h compile and run as I wanted only
to add a call to a class or function that had been there but had
not been previously used in main() and I get compiler errors. EX:
say I have CLASS1 and CLASS2. I create an instance of CLASS1 in
main and it compiles and runs fine. I then create an instance of
CLASS2, but get compiler errors for code that was there the whole
time. This also happens when using functions not used before.
How do I compile the entire header so that I can find all errors
without instantiating each class and calling each function of
each class? I have a>7200 line header and would rather not make
a call to absoluteley every function just to compile it. Thanks
ta0kira
 
 

Re:How to compile an entire header?

"ta0kira" < XXXX@XXXXX.COM >writes:
Quote
How do I compile the entire header so that I can find all errors
without instantiating each class and calling each function of
each class? I have a>7200 line header and would rather not make
a call to absoluteley every function just to compile it.
It seems that you are referring to templates defined in this header. It is
a feature that certain aspects of templates are only checked when the template
is instantiated.
E.g. this is ok:
template <typename T>
class Template
{
public:
void f(T &t)
{
t.x();
}
};
int main()
{
Template<int>t;
}
The compiler has to partially parse member function f() to find out that
it's a member function and where it ends (and some other things). OTOH, the
check for the existince of the member function T::x is only done when the
member function f() is instantiated, e.g. as a result of the line
t.f(t);
In other words: it is a Good Thing that many things aren't detected unless
you generate the specific instantiations.