使用 Auto C++ 突出显示 Eclipse 错误

Eclipse Error Highlighting with Auto C++

我在使用 Eclipse C++ 语法高亮显示时遇到问题 我正在使用从这里安装的 Eclipse-cpp 版本 4.7.3-1:https://www.archlinux.org/packages/?name=eclipse-cpp

我有以下代码:

for (auto& i : entityFactories) {
        if (i->getFactoryName() == type) {
            worldEntities.push_back(i->loadEntity(d, *this));
        }

    }

这段代码在eclipse中时,会被高亮标记为"Method could not be resolved"。但是,代码仍然构建成功,没有错误。

当我将代码更改为

for (EntityFactory* i : entityFactories) {
        if (i->getFactoryName() == type) {
            worldEntities.push_back(i->loadEntity(d, *this));
        }

    }

问题已解决。这是 Eclipse 中 auto 关键字的问题吗?或者是否有一些我可以更改的设置,以便我可以毫无问题地使用 auto 关键字?我在这里 post 试过:Eclipse C/C++ Shows Errors but Compiles? 但这并没有解决我的问题。

您需要配置 Eclipse 以使用 C++0x 或更新版本。查看这篇文章:Guide to Eclipse with C++11 standard.