Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Little Problem compiling

Little Problem compiling

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doctorpi
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • D doctorpi

      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

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • M Mike Dimmick

        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

        D Offline
        D Offline
        doctorpi
        wrote on last edited by
        #3

        Thanks guy I'll take a look about this. The point then is replace includes by class where possible? Doc

        R 1 Reply Last reply
        0
        • D doctorpi

          Thanks guy I'll take a look about this. The point then is replace includes by class where possible? Doc

          R Offline
          R Offline
          Roland Pibinger
          wrote on last edited by
          #4

          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;
          };
          
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups