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. Visual Studio
  4. VS2008 weird behavior regarding greyed out code in preprocessor directives

VS2008 weird behavior regarding greyed out code in preprocessor directives

Scheduled Pinned Locked Moved Visual Studio
c++databasehelptutorialquestion
5 Posts 2 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.
  • A Offline
    A Offline
    Andy411
    wrote on last edited by
    #1

    I have a VS2008 solution with different C++ projects. It is a legacy solution which is still in production and has to be maintained and enhanced in the next years. Some of the classes are usesd in different projects of the solution. Each solution has a compiler switch that tells the compiler which project is currently compiled. In code you will often find something (ugly) like: Declaration:

    class FooClass
    {
    public:
    void FncA();
    #ifdef APP_1_EXE
    void FncB();
    #endif

    #ifdef APP_2_EXE
    void FncC();
    #endif
    };

    Implementation:

    void FooClass::FncA()
    {
    // do something
    #ifdef APP_1_EXE
    // do special stuff for APP 1
    #endif
    }

    #ifdef APP_1_EXE
    void FooClass::FncB()
    {
    }

    #endif

    #ifdef APP_2_EXE
    void FooClass::FncC()
    {
    }
    #endif

    Now I have the behavior that APP_1 is active, but in the header file the code is greyed out and in the cpp module code is not greyed out. Even if I right click on the declarations in the header file, I cannot select "goto references" or "goto declaration" in the conext menue. In the class explorer the methods are inaccessible even if the compiler switch is set. For me it looks like VS2008 does not recognize the current active project. Any ideas or hints how to solve the problem? Maybe a good google query? After two days I'm out of ideas :-( Thx Andy PS: The problematic behaviour resides already for a while but it became massiv after I started to refactor and splitted the main header file which contained almost all class declarations into seperate header files. Now each class has it's own header file and it's own implementation file (liek FooClass.h and FooClass.cpp) I also know that it would be better to have a base class an use project specific derived classes instead of preprocessor switches but as I explained at the top: It's legacy code and I'm just at the beginning of the refactoring process.

    L 1 Reply Last reply
    0
    • A Andy411

      I have a VS2008 solution with different C++ projects. It is a legacy solution which is still in production and has to be maintained and enhanced in the next years. Some of the classes are usesd in different projects of the solution. Each solution has a compiler switch that tells the compiler which project is currently compiled. In code you will often find something (ugly) like: Declaration:

      class FooClass
      {
      public:
      void FncA();
      #ifdef APP_1_EXE
      void FncB();
      #endif

      #ifdef APP_2_EXE
      void FncC();
      #endif
      };

      Implementation:

      void FooClass::FncA()
      {
      // do something
      #ifdef APP_1_EXE
      // do special stuff for APP 1
      #endif
      }

      #ifdef APP_1_EXE
      void FooClass::FncB()
      {
      }

      #endif

      #ifdef APP_2_EXE
      void FooClass::FncC()
      {
      }
      #endif

      Now I have the behavior that APP_1 is active, but in the header file the code is greyed out and in the cpp module code is not greyed out. Even if I right click on the declarations in the header file, I cannot select "goto references" or "goto declaration" in the conext menue. In the class explorer the methods are inaccessible even if the compiler switch is set. For me it looks like VS2008 does not recognize the current active project. Any ideas or hints how to solve the problem? Maybe a good google query? After two days I'm out of ideas :-( Thx Andy PS: The problematic behaviour resides already for a while but it became massiv after I started to refactor and splitted the main header file which contained almost all class declarations into seperate header files. Now each class has it's own header file and it's own implementation file (liek FooClass.h and FooClass.cpp) I also know that it would be better to have a base class an use project specific derived classes instead of preprocessor switches but as I explained at the top: It's legacy code and I'm just at the beginning of the refactoring process.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You may just need to rebuild the projects as moving files and changing headers takes some time to be recognised. Try a Clean and Build of your complete solution.

      A 1 Reply Last reply
      0
      • L Lost User

        You may just need to rebuild the projects as moving files and changing headers takes some time to be recognised. Try a Clean and Build of your complete solution.

        A Offline
        A Offline
        Andy411
        wrote on last edited by
        #3

        Thx for the hint. Unfortunately it does not help. I also tried to delete the ncb file of the solution. It has no effect, either. At the moment I have two assumptions: 1) It has to do something with the size of the source files. There are several files with more (!) than 10k lines (no joke! As I told in my first post: Lot's of legacy stuff from more then 15 years) 2) Maybe something goes wrong with the bsc files (browse source) Regards, Andy PS: At the moment I'm at the beginning of a huge refactoring process. It can only be done step by step. Otherwise it (and I) will loose the acceptance of the colleages. They are usesd to work with these huge files...

        L 1 Reply Last reply
        0
        • A Andy411

          Thx for the hint. Unfortunately it does not help. I also tried to delete the ncb file of the solution. It has no effect, either. At the moment I have two assumptions: 1) It has to do something with the size of the source files. There are several files with more (!) than 10k lines (no joke! As I told in my first post: Lot's of legacy stuff from more then 15 years) 2) Maybe something goes wrong with the bsc files (browse source) Regards, Andy PS: At the moment I'm at the beginning of a huge refactoring process. It can only be done step by step. Otherwise it (and I) will loose the acceptance of the colleages. They are usesd to work with these huge files...

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry but I have no other suggestions. Whenever I have seen this it has always cleared up after a rebuild.

          A 1 Reply Last reply
          0
          • L Lost User

            Sorry but I have no other suggestions. Whenever I have seen this it has always cleared up after a rebuild.

            A Offline
            A Offline
            Andy411
            wrote on last edited by
            #5

            Anyway thanks a lot for your time and support. Regards, Andy

            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