会员声明未找到 [英] Member declaration not found

查看:433
本文介绍了会员声明未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一个使用常规文本编辑器的c ++项目上工作。
稍后,我将所有文件导入到Eclipse中,使调试变得更简单。



在Eclipse中,一件奇怪的事情发生了。
即使我已经包含头文件,它也抱怨会员声明未找到。
头文件具有函数定义。



如何解决这个问题?



提前感谢

解决方案

成员声明未找到是由Eclipse静态分析工具(柯顿)。如果你收到这个错误,但编译成功这是一个错误的肯定。已知此工具的较旧版本会给出一些假阳性,例如这个错误报告。所以我建议将Eclipse CDT更新到最新版本。



可能导致此错误的另一件事是一个未解决的包含,可以防止Eclipse正确解析部分代码。选择索引 - >在项目的上下文菜单中搜索未解决的包含将为您提供未解决的包含的列表。有关如何解决问题的详细信息,请参阅此答案



这是一个例子:

  class C {
void f(std :: vector< int>&);
};

void C :: f(std :: vector< int>&){} //没有找到会员声明

上述示例导致Eclipse CDT中的成员声明未找到错误,即使您已经包含< vector> 但未解决(由于配置错误包括路径)。


I have worked on a c++ project using a regular text editor. Later, I imported all the files to Eclipse to make it debugging easier.

In Eclipse a weird thing happens. It complains "Member declaration not found" even if I have included the header file. The header file has the function definition.

How do I fix this problem?

Thanks in advance

解决方案

"Member declaration not found" is an error produced by the Eclipse static analysis tool (codan). If you get this error, but the compilation succeeds this is a false positive. Older versions of this tool are known to give some false positives, see for example this bug report. So I recommend updating Eclipse CDT to the most recent version.

Another thing that may cause this error is an unresolved include that prevents Eclipse from parsing a portion of your code correctly. Selecting Index -> Search For Unresolved Includes in the context menu of the project will give you the list of unresolved includes. See this answer for the details of how to fix it.

Here's an example:

class C {
  void f(std::vector<int>&);
};

void C::f(std::vector<int>&) {} // Member declaration not found

The above example causes "Member declaration not found" error in Eclipse CDT even if you have <vector> included but unresolved (due to misconfigured include paths).

这篇关于会员声明未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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