我在 CentOS 6.5 x64 操作系统上运行并使用 yum 安装 Armadillo 。我在 Eclipse CDT 中开发
我在项目属性 >> C/C++ 构建 >> 设置 >> GCC C++ 编译器 >> 包含 >> 包含文件中包含了 Armadillo header 。条目是:“/usr/include/armadillo”
我正在处理的头文件可以识别 Armadillo 并且 include 语句没有标记任何错误或警告。
代码如下:
#include <armadillo>
using namespace std;
using namespace arma; // arma is not recognized as a symbol
const double DEGREES_PER_RADIAN = 180.0 / datum::pi; // datum is not recognized
我检查了文件 /usr/include/armadillo
,它确实包含命名空间 arma 部分。
//! \namespace arma namespace for Armadillo classes and functions
namespace arma
{
// preliminaries
...
我还检查了权限,/usr/include/armadillo
文件对所有用户都是可读的。
问题是当我添加“使用命名空间 arma”时,CDT 将其标记为错误并提示“无法解析符号‘arma’”。
在这一点上,我没有任何其他想法来弄清楚为什么命名空间无法被识别。任何解决这个问题的见解或指示将不胜感激。
最佳答案
这个问题的答案为我的问题提供了答案: Clean Eclipse Index, it is out of sync with code
Josh Kelley 在相关问题中的回答:
Right-click on your project, go under the Index submenu, and choose either "Rebuild," "Update with modified files," or "Freshen all files."
I don't know the difference between those three options, but one of "Update with modified files" or "Freshen all files" usually fixes it for me.
Also, I'm sure you've already done this, but make sure that you're running the latest version of the Eclipse CDT. Current versions seem to have much more reliable indexing than previous versions.
运行 Index >> Rebuild and Index >> Freshen All Files 后,错误消失了。
关于c++ - 带 Armadillo 的 Eclipse CDT 项目 - CDT 无法识别 'arma' 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27003438/