Visual Studio C++ 2005-2013 中的智能感知中缺少函数定义

Function definitions missing from intellisense in Visual Studio C++ 2005-2013(Visual Studio C++ 2005-2013 中的智能感知中缺少函数定义)

本文介绍了Visual Studio C++ 2005-2013 中的智能感知中缺少函数定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下问题长期困扰我的一个项目:

某些函数定义(来自 .cpp 文件)从智能感知中排除/隐藏!

这些功能无法转到定义",导航栏中也未列出.

不过,这些函数确实出现在自动完成列表中.问题仅针对 .cpp 文件,.h 文件解析良好.转到声明"也有效.

自 2005 年以来都是如此,对于每个新版本,我都希望得到修复,但其他人似乎并未将其视为错误.

更新:我已经将其归结为以下几点:intellisense 无法识别包含某个宏的所有函数.原来的宏是

#define forlist(x,list) for( auto x= list.begin(); x.valid(); ++x)

但您也可以使用简化的测试用例

#define fortest(x) for( auto x= 1; x<2; ++x)void myclass::TestFN(){森林(克){G;}}

下一步是寻找解决方法(或尝试通过 micrsoft 错误报告).

请不要过多地谈论这个宏.这是我无法更改的列表实现的现有代码.我不能使用宏,但我仍然认为这是一个 VS 错误.

一件有趣的事情是,以下(真正的 ***ic 宏)工作正常:

#define fortest(x) for( auto x= 1; x<2; ++x) {void myclass::TestFN(){森林(克)G;}}

会不会是intellisense把case 1当成一个非法的局部函数定义?(参见 http://connect.microsoft.com/VisualStudio/feedback/details/781121/c-intellisense-mistakes-loop-expression-for-function-definition)

以下也可以正常工作

#define fortest(x) for( auto x= 1; x<2; ++x)void myclass::TestFN(){森林(克)G;}

解决方案

像往常一样,几个小时后对我的问题的兴趣减弱了,所以我不得不自己弄清楚......

我们只需要使用 cpp.hint 文件的概念.

基本上,您必须将麻烦的宏放入名为 cpp.hint 的文件中,并将该文件放入您的解决方案目录中(这对我不起作用)或者在您的代码文件所在的父目录中.(为我工作)

在那个文件中,我们只将麻烦的宏放在没有右手边的地方,例如:

#define forlist(x,list)

<块引用>

注意:您必须重置 IntelliSense 缓存才能使用更改后的 cpp.hint 文件中的新数据.你应该:

  • 删除ipch文件夹(通常放在Solution文件夹中).
  • 删除解决方案文件夹中的所有 *.sdf 文件.
  • 删除Solution文件夹或ipch文件夹中的所有*.VC.db文件.

对于更高级的宏(例如代码块的开始"和结束"宏),还有一些其他技巧.

原文链接是:http://msdn.microsoft.com/en-us/library/dd997977.aspx

出现问题的原因是,如果 Intellisense 必须解析项目中的所有宏,它的性能会(可能)显着下降,因此它只解析 'cpp.hint' 中明确给出的那些.

The following problem plagues one of my projects for a long time:

Some function definitions (from .cpp files) are excluded/hidden from intellisense!

It is not possible to "Goto Definition" for those functions, nor are the listed in the Navigation Bar.

The functions do appear in the autocompletion list, though. The problem is for .cpp files only, the .h files are parsed fine. 'Goto Declaration' works, too.

This is the same since 2005, with every new version, I was hoping for a fix, but it does not seem to be regognized as a bug by anyone else.

UPDATE: I have tracked this down to the following: All functions containing a certain macro are not recognized by intellisense. The original macro was

#define forlist(x,list) for( auto x= list.begin(); x.valid(); ++x)

but you can also use the simplified test case

#define fortest(x)  for( auto x= 1; x< 2; ++x)

void myclass::TestFN()
{
    fortest( g )
    {
        g;
    }
}

Next step would be to find a workaround (or try to go through micrsoft bug reporting).

Please don't rant too much about this macro. This is existing code of a list implementation which I am not able to change. I could just NOT use the macro, but I still think this is a VS bug.

One funny thing is, that the following (really ***ic macro) works fine:

#define fortest(x)  for( auto x= 1; x< 2; ++x) {

void myclass::TestFN()
{
    fortest( g )
        g;
    }
}

Could it be that intellisense treats case 1 as an illegal local function definition? (see http://connect.microsoft.com/VisualStudio/feedback/details/781121/c-intellisense-mistakes-loop-expression-for-function-definition)

The following work fine, too

#define fortest(x)  for( auto x= 1; x< 2; ++x)

void myclass::TestFN()
{
    fortest( g )
        g;
}

解决方案

As usual, interest in my question ebbed up after a couple of hours, so I had to figure it out by myself...

We just 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) OR in a parent-directory where your code files reside in. (worked for me)

In that file we just put the troublesome macros WITHOUT right-hand-side, so e.g.:

#define forlist(x,list)

NOTE: Your must reset IntelliSense cache for use new data from changed cpp.hint file. You should:

  • delete ipch folder (usually placed in Solution folder).
  • delete all *.sdf files in Solution folder.
  • delete all *.VC.db files in Solution folder or in ipch folder.

For more advanced macros (like having 'start' and 'end' macros for code blocks), there are some other tricks.

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'.

这篇关于Visual Studio C++ 2005-2013 中的智能感知中缺少函数定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Visual Studio C++ 2005-2013 中的智能感知中缺少函数定义

基础教程推荐