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

问题描述

全部,

我有一个奇怪的问题,Intellisense for C ++项目。背景:我最近安装了VS2010 Sp1,并失去了Intellisense与SQL Server 2008 R2。我尝试安装累积更新7(CU7)推荐,这不工作。然而,重新安装SQL Server 2008 R2。然后我更新使用CU7的SQL Server 2008 R2和一切都很好。现在Intellisense工程罚款C#项目,但现在对于C ++项目,它不是很好的工作,因为它应该(注意:C ++项目是不是 C ++ / CLI)。

I have a strange issue with Intellisense for C++ projects. Background: I have recently installed VS2010 Sp1 and had a loss of Intellisense with SQL Server 2008 R2. I tried installing Cumulative Update 7 (CU7) as recommended and this did not work. Reinstalling SQL Server 2008 R2 however, did. I then updated using CU7 for SQL Server 2008 R2 and all was good. Now Intellisense works fine for C# projects but now for C++ projects it is not quite working as it should (NOTE: C++ project is not C++/CLI).

我已禁用预编译标题(不使用预编译标题),并包含以下内容:

I have disabled Precompiled Header ("Not Using Precompiled Headers") and have the following includes:

#include <cmath>
#include <complex>
#include <iostream>
#include "stdafx.h"
#include "globals.h"

using namespace std;

注意:我知道使用std命名空间并不总是最佳做法,

NOTE: I am aware that using the std namespace is not always considered best practise, but here it will save me allot of time and there is no chance of ambiguity.

现在当我想要一个printf语句,例如,如果我键入printf我得不到Intellisense提示。但是,如果我Ctrl +空格或Ctrl + J Intellisense识别命令,它显示。下面是Intellisense不自动工作的图像。

So now when I want a printf statement for example, if I type printf I get not Intellisense prompt. However, if I Ctrl+Space or Ctrl+J Intellisense is recognising the command, and it shows up. Below is the image of Intellisense not automatically working.

现在如果我输入std :: printf,Intellisense会出现:

Now if I type std::printf, Intellisense appears:

有什么办法让VS2010 / Intellisense知道我想使用std命名空间,因为它看起来像是只是没有识别#using namespace std;命令。

Is there any way to let VS2010/Intellisense know I want to use the std namespace because it appears like it is just not recognising the "#using namespace std;" command.

非常感谢。

推荐答案

:我的第二个答案。基于Cory Nelson的评论,所以我不要求信用。

Note: My second answer. Based on a comment by Cory Nelson, so I don't claim credit.

如果我正确理解你,你希望Intellisense弹出你的时刻类型p。

If I understand you correctly, you want that Intellisense pops up the moment you type 'p'.

答案是:否,VS2010不会这样做

Intellisense会输入:: p或std :: p,但不能输入一个普通的p。这与预编译的标头, #include 订单没有有关。它不会。

Intellisense will kick in for "::p" or "std::p", but not for a plain "p". This has nothing to do with precompiled headers, nor #include order. It just won't.

我过去使用的一些IDE有一个设置在这种情况下启用/禁用完成(我记得如此一些C ++ Builder版本),但我找不到它在VS2010。

Some of the IDEs I've worked with in the past have a setting to enable/disable completion in this case (I recall seeing so in some C++ Builder version), but I couldn't find it in VS2010.

那么为什么VS2010不允许呢?关键字可能导致不值得解决的问题,但是这是否是这里的原因?我不知道。也许VS团队的一个成员可以阐明这一点。

So why would VS2010 not allow it? Keywords could cause problems that are not worth solving, but whether that's the reason here? I don't know. Maybe a member of the VS team could shed some light on this.

更新:

我在一个新的VS2010项目中测试了这个程序:

I tested this program in a new VS2010 project:

#include <string>
using namespace std;

int main()
{
    stri
}


b $ b

键入stri时没有弹出窗口。

No popup while typing "stri".

string出现在ctrl空格后的弹出窗口中, 使用命名空间std; ,以便正确地对使用作出反应。

"string" appears in the pop-up after ctrl-space, and is absent when I remove the using namespace std; so it correctly reacts to the using.

键入 :: 后,Intellisense激活, :: s 建议SA_AccessType(从文件sourceannotations.h ),因此清单预先填充了许多系统标题。

After typing ::, Intellisense activates and after ::s suggests SA_AccessType (from the file sourceannotations.h), so the list is clearly prepopulated with many system headers.

如果我输入 if 并强制Intellisense弹出在列表中没有 if 。如果我然后键入,如果我想键入 if(,它更正为 ifstream(。因此,如果Intellisense总是弹出,就很难键入关键字。

If I type if and force Intellisense to pop-up, there is no if in the list. If I then type the ( as if I wanted to type if(, it corrects to ifstream(. So if Intellisense would always pop-up, it would be much harder to type keywords.

这篇关于在VS2010中的C ++的智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 17:23