Visual Studio C ++ 2005-2013中的intellisense中缺少函数定义 [英] Function definitions missing from intellisense in Visual Studio C++ 2005-2013

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

问题描述

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



某些函数定义(来自.cpp文件)从intellisense中被排除/隐藏!



这些功能无法转到定义,也不能在导航栏



但是,函数确实出现在自动完成列表中。问题是只有.cpp文件,.h文件解析得很好。 Goto Declaration也行。



这与2005年一样,每一个新版本,我希望有一个修复,但它似乎没有被识别



UPDATE:
我已经跟踪到以下内容:包含某个宏的所有函数不被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()
{
fortest(g)
{
g;
}
}

下一步是找到一个解决方法通过micrsoft bug报告)。



请不要太多关于这个宏。这是一个列表实现的现有代码,我不能改变。我可以不使用宏,但我仍然认为这是一个VS的bug。



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

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

void myclass :: TestFN()
{
fortest(g)
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()
{
fortest(g)
g;
}


解决方案

问题在几个小时后就消失了,所以我不得不自己想出来...



我们只需要使用 cpp.hint 文件。



基本上你必须把麻烦的宏放到一个名为 cpp.hint 并将该文件放在您的解决方案目录(对我来说不起作用)
OR在您的代码文件所在的父目录中(为我工作)



在该文件中,我们只是把麻烦的宏放在右手边,例如:

  #define forlist(x,list)



/ strong>:您必须重置IntelliSense缓存以使用更改的 cpp.hint 文件中的新数据。您应该:




  • 删除 ipch 文件夹/ li>
  • 删除解决方案文件夹中的所有* .sdf文件。

  • 删除解决方案文件夹或 ipch 文件夹。


'和'end'宏代码块),还有一些其他的技巧。



原始链接是:
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中的intellisense中缺少函数定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆