gpt4 book ai didi

android - 使用 c++11 std::async 在 android ndk 中无效使用不完整类型

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:46:54 25 4
gpt4 key购买 nike

我尝试使用以下函数来检查 std::async 是否在带有 Eclipse 的 android ndk 以及 Windows 中的 cygwin 中受支持。我使用的函数如下

机器:64bit win 8 with cygwin

安卓:r8e

eclipse :朱诺 4.2.1

ADT:22.0.1

struct Foo
{
Foo() : data(0) {}
void sum(int i) { data +=i;}
int data;
};

int main()
{
Foo foo;

auto f = std::async(&Foo::sum, &foo, 42);
f.get();
std::cout << foo.data << "\n";
}

我收到以下错误:

描述资源路径位置类型无效使用不完整类型 'std::__async_sfinae_helper::type {aka struct std::future}' Sample.cpp/Cli13/jni line 63 C/C++ Problem

注意:我已经设置了 _GLIBCXX_HAS_GTHREADS 和 GXX_EXPERIMENTAL_CXX0X 以及 ATOMIC_INT_LOCK_FREE... 默认情况下,ndk 使用 4.6 工具链。我必须在 Properties-> C/C++ -> Includes 中手动包含 4.7 的 gnu-libstd++。是否有任何解决方法可以使 std::async 正常工作???

谢谢。

最佳答案

Android NDK r8e 不具备C++11 的完整运行时库支持。您将需要使用一些第三方 stdlib 编译您自己的 NDK,或者等待 Google 将 Clang 3.3 包含在 C++11 功能完整。

关于android - 使用 c++11 std::async 在 android ndk 中无效使用不完整类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17724722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com