简体   繁体   English

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

[英]Invalid use of incomplete type in android ndk using c++11 std::async

I tried to use the following function to check whether std::async is supported in android ndk with Eclipse along with cygwin in windows. 我尝试使用以下函数来检查android ndk中是否支持std :: async以及windows中的cygwin。 The function I used is the following 我使用的功能如下

Machine: 64bit win 8 with cygwin 机器:64位赢得8与cygwin

Android: r8e Android:r8e

Eclipse: Juno 4.2.1 Eclipse:Juno 4.2.1

ADT: 22.0.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";
}

I get the following error: 我收到以下错误:

Description Resource Path Location Type invalid use of incomplete type 'std::__async_sfinae_helper::type {aka struct std::future}' Sample.cpp /Cli13/jni line 63 C/C++ Problem 说明资源路径位置类型无效使用不完整类型'std :: __ async_sfinae_helper :: type {aka struct std :: future}'Sample.cpp / Cli13 / jni line 63 C / C ++问题

Note: I have set the _GLIBCXX_HAS_GTHREADS and also the GXX_EXPERIMENTAL_CXX0X along with the ATOMIC_INT_LOCK_FREE... By default the ndk uses 4.6 toolchain. 注意:我已经设置了_GLIBCXX_HAS_GTHREADS以及GXX_EXPERIMENTAL_CXX0X以及ATOMIC_INT_LOCK_FREE ...默认情况下,ndk使用4.6工具链。 I had to include the gnu-libstd++ for 4.7 manually in Properties-> C/C++ -> Includes. 我必须在Properties-> C / C ++ - > Includes中手动包含gnu-libstd ++ for 4.7。 Is there any work around to make the std::async working??? 是否有任何工作使std :: async工作???

Thank You. 谢谢。

Android NDK r8e does not have the full run-time library support of C++11 . Android NDK r8e没有C++11的完整运行时库支持。 You will need to compile your own NDK using some third-party stdlib or wait Google to include the Clang 3.3 in the NDK which is C++11 feature-complete. 您需要使用某些第三方stdlib编译自己的NDK,或者等待Google将Clang 3.3包含在NDK中,这是C++11功能完备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM