Why might the Q_FOREACH macro break VS2010 intellisense?

南笙酒味 提交于 2019-12-01 17:20:12

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!