I have a c++ project in VS2010 with Qt 4.7.4 and I frequently have problems with IntelliSense (as we all do...). A specific problem is that sometimes the function body (in the .cpp file) can't be found. If I click into that function body, the dropdown box (which usually shows the function you're in) is empty.
Today I noticed this behavior right after I added a foreach()
statement (the Qt macro Q_FOREACH). I then replaced the foreach() macro with a corresponding for(int i = 0; i < ...)
and IntelliSense immediately displayed the function again.
So I'd like to know:
You have to use the concept of 'cpp.hint' files.
Basically, you have to put the troublesome macros into a file named 'cpp.hint' and put that file in your solution directory (which did not work for me - non-standard project layout maybe) OR in a parent-directory where your code files reside in. (worked for me)
In that file you just put the troublesome macros WITHOUT right-hand-side, so in your case:
#define foreach()
or maybe better
#define Q_FOREACH(variable, container)
#define foreach(...)
etc.
NOTE, that you may have to ReScan or Restart or fiddle around with a function for the effect to set in after putting the definition in the cpp.hint file.
UPDATE: Indeed, I just found, that I have to make some change to a .cpp file (e.g. adding a new line) for the effect to kick in. The fix is not automatically applied.
The original link is: http://msdn.microsoft.com/en-us/library/dd997977.aspx
The reason for the trouble is that Intellisense performance would (potentially) decrease dramatically if it had to parse all macros in a project, so it only parses those given explicitly in 'cpp.hint'.
The original microsoft text says that you can use any directory in "The path from the root directory of a source file to the directory that contains the source file itself. In a typical Visual C++ project, the root directory contains the solution or project file."
You can find the main 'cpp.hint' file at 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcpackages' for reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With