【发布时间】:2018-03-24 02:44:09
【问题描述】:
我面对很多 说 Symbol 'array' could not be resolved,代码构建良好。
#include <math.h>
#include <array>
#include <sstream>
#include <string>
static std::string printArray(std::array<double, 3> data) {
std::ostringstream strs;
strs << "( " << data[0] << " " << data[1] << " " << data[2] << " )";
return strs.str();
}
static std::string printVector(std::vector<double> data) {
std::ostringstream strs;
strs << "( " ;
for (const auto & value : data )
strs << value << " ";
strs << " )";
return strs.str();
}
如here 或here 所述,使用C/C++ General -> Preposcessor Include Path, Macros etc. -> Porvides -> CDT GCC Built-in Compiler Settings 下的-std=c++11 标志激活c++11 功能。
我的问题没有重复,因为它适用于std::vector,并且其他 c++11 功能得到了正确处理。
按 F3 可以解析标题 (#include <array>)。
我正在使用 Eclipse 的 CDT 版本:Neon.3 Release (4.6.3)。
【问题讨论】:
-
在构建过程中我没有收到任何错误。我正在使用基于 Makefile 的构建。
-
@VT,我认为这不是重复的。我做了那里建议的步骤。他们为
std::vector工作,但不为std::array工作。 -
accepted answer 在您链接到用于设置
-std=c++11标志的问题中,它没有提到“Preposcessor[sic] Include Path, Macros etc.” -
你试过重建索引吗?
-
@Someprogrammerdude:设置的位置从我正在使用的 neo3 的答案中使用的 Eclipse Indigo 20110615-0604 版本更改。
标签: c++ eclipse c++11 eclipse-cdt stdarray