Eclipse 3.7.1 CDT 1.4.1 GCC 4.6.2
这是一段C++ 11代码的示例:
auto text = std::unique_ptr<char[]>(new char[len]);
Run Code Online (Sandbox Code Playgroud)
Eclipse编辑器抱怨:
Function 'unique_ptr' could not be resolved
Run Code Online (Sandbox Code Playgroud)
Makefile编译工作正常.如何让Eclipse停止抱怨这些错误?
我在这段代码中使用std :: unique_ptr,它按照我的预期编译和运行.
std::stringstream out;
out << std::setw(3) << std::setfill('0') << i;
std::unique_ptr<std::string> s(new std::string(out.str()));
s->insert(s->end()-2, 1, '.');
return std::move(s);
Run Code Online (Sandbox Code Playgroud)
但是,我从Eclipse CDT收到错误消息.在第四行:无法解析方法"插入",无法解析方法"结束".
以前,我在名称std :: unique_ptr的外观上也遇到了错误.这是通过设置预处理器符号__GXX_EXPERIMENTAL_CXX0X__和重建索引来解决的,如本问题的答案中所述.
有没有办法让CDT理解s的类型是std :: string*并且它应该在std :: string中查找s-> insert()和s-> end()?
PS:我使用的是Eclipse 3.7.1和CDT 8.0.0.201106081058
PS2:我想在上面的问题中将其作为评论发布,但我不能,大概是因为我是新用户
我一直在尝试使用C++ 11.我正在开发一个Android项目,我想使用std :: mutex.与OpenCV一起但无论我做什么,我似乎无法修复Type 'mutex' could not be resolved
错误.
我试过按照我在SO和其他地方找到的教程. LINK1 LINK2 LINK3 LINK4
经过这么多教程,它现在已成为一个真正的混乱.所以我将解释我目前的设置
项目>属性> C/C++构建>发现选项
项目> C/C++一般>路径和符号>#符号选项卡
在我的Application.mk文件中,我有以下内容
APP_STL := gnustl_static
APP_USE_CPP0X := true
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
Run Code Online (Sandbox Code Playgroud)
我试图将cplusplus符号的值更改为201103L并尝试使用空值的__GXX_EXPERIMENTAL_CXX0X
但似乎什么都没有用,我做错了什么?
任何帮助表示赞赏!
给出以下示例代码:
#include <iostream>
#include <memory>
using namespace std;
struct A {
public:
A(int aa) : a(aa) {}
int a;
virtual ~A() {}
};
struct B : A {
public:
B(int aa, int bb) : A(aa), b(bb) {}
int b;
};
void f(shared_ptr<A> a){
shared_ptr<B> b = dynamic_pointer_cast<B>(a);
if (b) {
cout << b->b << endl;
} else {
cout << a->a << endl;
}
}
int main() {
auto a = make_shared<A>(3);
auto b = make_shared<B>(7, 4);
f(a);
f(b);
return …Run Code Online (Sandbox Code Playgroud) eclipse ×5
c++ ×4
c++11 ×4
eclipse-cdt ×2
android ×1
android-ndk ×1
ide ×1
linux ×1
polymorphism ×1
stl ×1
unique-ptr ×1