【问题标题】:C++/CLI Errors in Intellisense, Compiles fineIntellisense 中的 C++/CLI 错误,编译正常
【发布时间】:2015-05-06 03:39:31
【问题描述】:

...有人知道如何解决这些问题吗?

Visual Studio 2011 Beta,试图让一些框架为此做好准备,现在解决了有限的问题列表。

代码是:

String^ pUser = (System::String^) pConnectionStringBuilder["UserName"];
String^ pPass = (System::String^) pConnectionStringBuilder["Password"];
String^ pBroker = (System::String^) pConnectionStringBuilder["Broker"];

pConnectionStringBuilder 是 ConnectionStringBuilder 的一个实例。

错误:

2   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  39  Tradex.Connectivity.Rithmic
3   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  64  Tradex.Connectivity.Rithmic
4   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  63  39  Tradex.Connectivity.Rithmic
5   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  63  64  Tradex.Connectivity.Rithmic
6   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  64  41  Tradex.Connectivity.Rithmic
7   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  64  66  Tradex.Connectivity.Rithmic
8   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  269 6   Tradex.Connectivity.Rithmic
9   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  269 32  Tradex.Connectivity.Rithmic

它们根本没有任何意义;)

还有另外两个警告,但很明显这不是错误:

1> Tradex.Connectivity.Rithmic.vcxproj -> C:\Work\Tradex\Source\Debug\Tradex.Connectivity.Rithmic.dll rithmicconnector.cpp(104):警告:C6001:使用未初始化的内存“oParams”。 rithmicconnector.cpp(108):警告:C6001:使用未初始化的内存“oLoginParams”。 1> 代码分析完成 -- 0 个错误,0 个警告

它编译得很好。

我尝试使用 pConnectionStringBuilder->default - 你猜怎么着 ;) 抱怨。

2   IntelliSense: class "System::Data::Common::DbConnectionStringBuilder" has no member "default"   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  65  Tradex.Connectivity.Rithmic

这也是错误的,它可以编译;)

我真的不希望出现 Intellisense 错误。

【问题讨论】:

  • 这里显然是键盘-椅子界面问题,更换该模块,您的问题就会消失 :)

标签: visual-studio-2012


【解决方案1】:

用于 C++/CLI 的 Intellisense 经常会感到困惑并报告误报错误。它根本不如 C# 的 Intellisense。公平地说,C++ 代码通常比 C# 代码更难增量分析(例如,如果我将单个 #define pragma 添加到头文件中,则导入头文件的任何文件的结构都可能会完全改变 /em>)。

一旦我开始看到虚假的 Intellisense 错误,我通常会在错误列表窗口中将其关闭:

  1. 右键单击错误列表窗口的内容
  2. 取消选中“显示 Intellisense 错误”

【讨论】:

  • @NickBedford 我称之为令人放心。这里没有天网的机会 - 可能找不到核火箭开始;)
【解决方案2】:

如果您一直在使用 C++ 并受到 Intellisense 错误的困扰,您可能希望永久关闭此错误报告: 工具 -> 选项 -> 文本编辑器 -> C/C++ -> 高级 -> IntelliSence -> 禁用错误报告

【讨论】:

  • 这就是你应该做的。只需禁用它。非常感谢@Manuel。
【解决方案3】:

我发现如果一个文件没有换行符结束(例如,包含文件的最后一行是 #endif 并且后面没有 CRLF),它会弄乱 Intellisense 并导致它标记错误。

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    • 2018-09-02
    • 2016-06-02
    相关资源
    最近更新 更多