views:

11005

answers:

8

Hi, does anyone know how to get intellisense to work reliably when working in C/C++ projects? It seems to work for about 1 in 10 files. Visual Studio 2005 seems to be a lot better than 2008.

Edit: Whilst not necessarily a solution, the work-around provided here:

http://stackoverflow.com/questions/39474/how-to-get-intellisense-to-reliably-work-in-visual-studio-2008#39590

Is probably the best bet if I want a decent intellisense system.

+12  A: 

Native C++ intellisense does not work reliably in any version of Visual Studio. I find there are two common problems:

1) Header file paths are not set-up correctly. When you find a type where intellisense is not working, use the IDE to click through each header file to find the one containing the type. (Right click on #include and select Open Document...). If this fails before you get to the file which declares the type then this is your problem. Make sure header file search paths are set-up correctly.

And,

2) The intellisense database is corrupt. This happens ALL The time. You need to close the solution, delete the .ncb file, and then reopen the solution. I posted the macro I use for this in answer to another question here.


The preprocessor can also confuse intellisense - so make sure any #defines during build are also available to intellisense. Other than that, I don't know what else can break it. I've not seen any particular issues with forward declarations.

John Richardson
Thats a helpful solution to delete the ncb file. :)
sn3ek
+1  A: 

I don't use VS2008 for C++, only VB & C#, but I find that when intellisense stops working (true for VS2003/2005/2008) it's because something in the project/file is broken - usually a bad reference or code.

VB and C# have much better intellisense support due to the ability to reflect on the referenced assemblies to build the intellisense tree.

C++ has to walk the include files for function prototypes, and if the paths are not correct it will not find all the prototype headers.

FlySwat
+1  A: 

@John Richardson / @Jonathan Holland

My includes are setup correctly, no problems there. I've also tried the NCB rebuild several times but it never fixes it 100%.

I have a feeling it may be to do with forward declarations of classes. e.g. to reduce the complexity of includes in header files we normally do something like:

class MyPredeclared;

class SomeOtherClass
{
private:
    MyPredeclared* m_pPointer;
}

I wonder if that screws it up? Any other ideas? It definitely gets worse the larger your project gets.

Mark Ingram
+3  A: 

Do you have any add-ins installed (or uninstalled)? I find that effects my intellisense. Besides that just making sure your Tools->Options->All Languages "Auto LIst Members" and "Parameter Information" are checked off.

Sara Chipps
Thanks, this helped me figure out why Intellisense mysteriously stopped working!
Peter Bernier
+14  A: 

I've also realized than Intellisense is sometime 'lost', on some big project. Why? No idea.

This is why we have bought Visual Assist (from Tomato software) and disabled Intellisense by deleting the dll feacp.dll in the Visual studio subdirectory (C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages)

This is not a solution, just a workaround.

Steve Gury
+5  A: 

It looks like there's hope on the horizon for those of us unable to obtain Visual Assist:

Rebuilding Intellisense

Nick McCowin
But no support for C++/CLI in the first release of VS2010 :/
demoncodemonkey
A: 

Help... I cannot get any of these to work. I reinstalled VS 2008 and SP1. I changed the options for Statement Completion, etc. In my situation, the Hide advanced members has a green box inside the checkbox. Doesn't matter if I turn it off or turn it on, after closing the solution and reopening, it returns to a green box inside the checkbox. The net result is I do not have color coding or intellisense in my ASPX files.
If an yone else has encountered this, please help a bloke out! I am ready to go back to VS 2005 now.

Drew
+1  A: 

My fix to itellisense was required after that awful refactor utility minced my code. The problem was a class header file that included an #include of itself. The recursive reference destroys itellisense. A symptom of this is if itellisense can see other classes but not the current one. Also:

Use #pragma once to eliminate duplicate header loads

If the project now takes a very much longer time to load, that itellisense trying to make sense of the conflict that is causing then lack of completion support.

Often it is only one class object that is affected, This shows you what files (usually headers) to look at.

TW Burger