Eclipse CDT无法解析std:array,std :: vector工作正常
我面临很多说
Symbol 'array' could not be resolved
,代码构建正常。Eclipse CDT无法解析std:array,std :: vector工作正常
#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();
}
的C++ 11特征描述或here使用-std=c++11
标志C/C++ General -> Preposcessor Include Path, Macros etc. -> Porvides -> CDT GCC Built-in Compiler Settings
下活化。
我的问题是没有重复,因为它适用于std::vector
和其他C++ 11功能处理正确。
标题(#include <array>
)可以通过按F3来解决。
我使用Eclipse的CDT版本:Neon.3版本(4.6.3)。
问题是符号__cplusplus
没有值201103L。
要改变这一点,你需要
编辑
Project->Preferences->C/C++ General/C/C+ General->Paths and Symbols->GNU C++->Symbols
加定义__cplusplus
和设定值201103L
setzen。下添加
Window->Preferences->C/C++/Build/Settings/Discovery/CDT GCC Build-in Compiler Settings
DAS论证 “-std = C++ 11” 明镜命令行hinzufügen激活
Project->Preferences->C/C++ General/C/C++ General/Path and Symbols->Providers
所有条目下的复选框Use global provider shared between projects
我dont't得到任何错误在构建期间。我正在使用基于Makefile的构建。 – schorsch312
@VT,我认为这是不公布的。我在那里提出了建议的步骤。他们为'std :: vector'工作,而不是'std :: array'。 – schorsch312
在你为了设置'-std = C++ 11'标志而链接到的问题中的[接受的答案](https://stackoverflow.com/a/9135135/440558),它没有提到“Preposcessor [sic ]包括路径,宏等“ –