C++/CLI Errors in Intellisense, Compiles fine

主宰稳场 提交于 2021-02-19 03:26:26

问题


...anyone an idea how to fix those?

Visual Studio 2011 Beta, trying to get some frameworks prepared for that and now going through a limited list of issues.

The code is:

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

pConnectionStringBuilder is an instance of ConnectionStringBuilder.

The errors:

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

and they simply make NO sense at all ;)

There are two other warnings, but quite obviously that is not an error:

1> Tradex.Connectivity.Rithmic.vcxproj -> C:\Work\Tradex\Source\Debug\Tradex.Connectivity.Rithmic.dll rithmicconnector.cpp(104): warning : C6001: Using uninitialized memory 'oParams'. rithmicconnector.cpp(108): warning : C6001: Using uninitialized memory 'oLoginParams'. 1> Code Analysis Complete -- 0 error(s), 0 warning(s)

It compiles fine.

I tried to use pConnectionStringBuilder->default - guess what ;) Complains.

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

which incidentally also is wrong and it compiles ;)

I really prefer not to have Intellisense errors.


回答1:


Intellisense for C++/CLI will often get confused and report false-positive errors. It is simply not as good as Intellisense for C#. To be fair, C++ code in general is much harder to analyze incrementally than C# code (e.g., if I add a single #define pragma into a header file, the structure of any file that imports the header file may change completely).

Once I start seeing spurious Intellisense errors, I usually just turn them off in the Error List window:

  1. Right-click the contents of the Error List window
  2. Uncheck "Show Intellisense Errors"



回答2:


If you are always working in C++ and are bothered by Intellisense errors, you may want to switch off permanently this Error reporting : Tools -> Option -> Text Editor -> C/C++ -> Advanced -> IntelliSence -> Disable Error Reporting




回答3:


I've found that if a file ends without a newline (e.g. the last line of the include file is #endif and there's no CRLF after it) it will mess up Intellisense and cause it to flag errors.



来源:https://stackoverflow.com/questions/9732639/c-cli-errors-in-intellisense-compiles-fine

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