Little Problem compiling
-
Hi guys I'm working in an app that starts to be big and I have a little-big problem. When I touch an .h file the VC++ 6.0 recompiles practically the complete app. Why do you think this is due to? There is some Setting to change? Is due to includes? Some clue? Have you experimented this too? ;) Thanks in forwarding Doc
-
Hi guys I'm working in an app that starts to be big and I have a little-big problem. When I touch an .h file the VC++ 6.0 recompiles practically the complete app. Why do you think this is due to? There is some Setting to change? Is due to includes? Some clue? Have you experimented this too? ;) Thanks in forwarding Doc
Visual C++ will recompile any file that it decides is dependent on that file. If you edit a commonly-used header, it will recompile most of the application. To resolve this, first remove any unnecessary includes from source files - only include those headers actually required. If you're using a precompiled header file (a default VC project uses StdAfx.h as the header file for generating precompiled headers) you should only include in that header headers that are very stable. In some cases you may have used #include in a header file where the actual definition is not required - i.e. the class declared in the header is only passed or stored as a pointer or as a reference. If this is the case you can remove the #include and only give a forward declaration, e.g.
// Before
#include "MyClass.h"
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );private:
MyClass* m_pMyClass;
};// After
class MyClass;
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );private:
MyClass* m_pMyClass;
};If this is still causing too much to be regenerated, you can use a trick called, variously, a compilation firewall, the Cheshire Cat technique, or the Pimpl Idiom[^]. Pimpl stands for Pointer-to-implementation. Stability. What an interesting concept. -- Chris Maunder
-
Visual C++ will recompile any file that it decides is dependent on that file. If you edit a commonly-used header, it will recompile most of the application. To resolve this, first remove any unnecessary includes from source files - only include those headers actually required. If you're using a precompiled header file (a default VC project uses StdAfx.h as the header file for generating precompiled headers) you should only include in that header headers that are very stable. In some cases you may have used #include in a header file where the actual definition is not required - i.e. the class declared in the header is only passed or stored as a pointer or as a reference. If this is the case you can remove the #include and only give a forward declaration, e.g.
// Before
#include "MyClass.h"
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );private:
MyClass* m_pMyClass;
};// After
class MyClass;
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );private:
MyClass* m_pMyClass;
};If this is still causing too much to be regenerated, you can use a trick called, variously, a compilation firewall, the Cheshire Cat technique, or the Pimpl Idiom[^]. Pimpl stands for Pointer-to-implementation. Stability. What an interesting concept. -- Chris Maunder
-
Thanks guy I'll take a look about this. The point then is replace includes by class where possible? Doc
doctorpi wrote: The point then is replace includes by class where possible? Yes. Here are some hints of what is possible:
#include "notpossible.h"; class Possible; class MyClass { public: Possible foo (Possible v, const Possible& r, Possible* p); void bar() { NotPossible n = 3; } private: NotPossible nope; };