以下问题困扰了我的一个项目很长一段时间:
一些函数定义(来自.cpp文件)被从智能感知中排除/隐藏!
这些功能无法" 转到定义 ",也不能在导航栏中列出.
但是,这些功能确实出现在自动完成列表中.问题仅在于.cpp文件,.h文件被解析得很好."Goto宣言"也有效.
这是自2005年以来的相同,每个新版本,我都希望能够修复,但它似乎没有被任何其他人认定为错误.
更新: 我已将此跟踪到以下内容:intellisense无法识别包含某个宏的所有函数.原来的宏是
#define forlist(x,list) for( auto x= list.begin(); x.valid(); ++x)
Run Code Online (Sandbox Code Playgroud)
但您也可以使用简化的测试用例
#define fortest(x) for( auto x= 1; x< 2; ++x)
void myclass::TestFN()
{
fortest( g )
{
g;
}
}
Run Code Online (Sandbox Code Playgroud)
下一步是找到一种解决方法(或尝试通过micrsoft bug报告).
请不要对这个宏咆哮太多.这是列表实现的现有代码,我无法更改.我可以不使用宏,但我仍然认为这是一个VS错误.
一个有趣的是,以下(真正的***ic宏)工作正常:
#define fortest(x) for( auto x= 1; x< 2; ++x) {
void myclass::TestFN()
{
fortest( g )
g;
}
}
Run Code Online (Sandbox Code Playgroud)
可能是intellisense将案例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()
{ …Run Code Online (Sandbox Code Playgroud)