locked
VC++ Express 2005 Intellisense and preprocessor Issue RRS feed

  • Question

  • I have converted a VC++ 6.0 workspace with 3 projects to Express 2005.  In general, it is working well.  All three projects share some code files and use preprocessor macros to enable/disable some code sections.  It all compiles and works fine in both versions of VC++. 

    What I noticed is that that intellisense seems to be confused (or I just don't know how to set it up) as to which macro definitions are active.  I set one project to be "Startup Project" (I assume this is the closest thing to the active project in VC++ 6) but the code is colored (active/inactive preprocessor segments) based on the first project (at least that is my best guess).  I would like to be able to select a project and have it use the preprocessor definitions in the properties for that project to properly determine which sections of code are active.

    The code coloring is wrong even when running the debugger on the project.  It is very confusing to be stopping at a break point inside of "inactive code".  Not to mention that class browsing won't work.

    Any idea?

    Thanks,
    Peter
    Wednesday, November 9, 2005 12:48 AM

Answers

All replies

  • I am sure the IDE folks would be interested in taking a look at the issue. Could you log it at http://lab.msdn.microsoft.com/productfeedback/default.aspx where they can have a look?

    You will need to provide a sample reproducing the issue.

    Thanks,
      Ayman Shoukry
      VC++ Team
    Wednesday, November 9, 2005 1:14 AM
  • Thanks for the QUICK reply!  I will work on creating a small example that exhibits the problem.

    Thanks,
    Peter
    Wednesday, November 9, 2005 1:16 AM
  •  

    I had the same problem until I added the path where my StdAfx.h resided to the preprocessor include paths. The fact that it can't find the StdAfx.h is verified by right clicking on the #include <StdAfx.h> line and selecting open document.

    Wednesday, January 25, 2006 4:29 PM
  •  

     Ayman Shoukry wrote:
    I am sure the IDE folks would be interested in taking a look at the issue. Could you log it at http://lab.msdn.microsoft.com/productfeedback/default.aspx where they can have a look?

    You will need to provide a sample reproducing the issue.

    Thanks,
      Ayman Shoukry
      VC++ Team

    I am having this exact same problem. We have a solution that contains a number of projects. Two of these projects (call them A and B) create executables, and include code that is shared, but a macro is defined in the preprocessor options for one project and not the other, so the shared code compiles differently for each of the two projects.

    For the first project (alphabetically), intellisense properly marks as inactive the inactive sections (i.e. no "Go to Definition" options and it's colored differently).

    For the second project (alphabetically), intellisense still thinks the macro is defined for the first project, and so code blocks are improperly marked as inactive.

    The only solution we've found that works is to use three solutions -- one with both, for batch building, one with project A removed, and one with project B removed. This is a nuisance because we've worked with the combined solution in Visual Studio 2003 and prior for years, but the inactive code block stuff is new (and broken).

    Without getting into specific code or project names, here's how things are organized

    Solution:

    Project A (in the project preprocessor options, the macro PROJECT_A is defined)

        Project A Specific Code

        Shared Code

            MyFile.cpp

        ,,,

    Project B (PROJECT_A is NOT defined in the project preprocessor options)

        Project B Specific Code

        Shared Code

            MyFile.cpp

        ....

    Within MyFile.cpp, there are sections like

    #ifndef PROJECT_A

        bool result = ProjectBSpecificFunction();

    #else

        bool result = ProjectASpecificFunction();

    #endif

    Now, whether I open up MyFile.cpp from Project A or from Project B, whether either of the projects is my Start Project, I can NEVER right click on ProjectBSpecificFunction(); or anything in the #ifndef PROJECT_A block and Go To Definition/Declaration. The ONLY way I've found to get around this is to create a solution that does not include Project A, which is counter to the way we've been working on our projects for years.

     

     

    Tuesday, May 2, 2006 5:13 PM
  • Same problem here.  The only way around this is separate solution files so separate NCB files are generated. 

    I hope that combining contents of many subprojects into a single NCB is vastly improved under SP1.

    Tuesday, May 2, 2006 5:27 PM
  • I am using SP1 with the professional version and still have this issue. Has anyone heard if this issue is being addressed by the development team?
    Saturday, June 16, 2007 12:28 AM
  • from discussion by Microsoft on other intellisense threads, the answer is no, these types of issues won't be addressed until the version after Visual Studio 2008 (Visual Studio 2010?)
    Monday, June 18, 2007 12:43 PM