I tried to get the following code sample working to find out if asynchronous programming works in Android NDK. Although the NDK has an STL <future> that is recognized as a header, std::async not recognized, not recognized. The code I tried to use was as follows:
#include <future> #include <iostream> 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"; }
Also, all included paths were installed in the specified folder under "Properties-> Paths and Symbols"
Errors Description Resource Path Location Type invalid use of incomplete type 'std::__async_sfinae_helper<void (Foo::*)(int), void (Foo::*)(int), Foo*, int>::type {aka struct std::future<void>}' Sample.cpp /Project12/jni line 50 C/C++ Problem Description Resource Path Location Type declaration of 'std::__async_sfinae_helper<void (Foo::*)(int), void (Foo::*)(int), Foo*, int>::type {aka struct std::future<void>}' Project12 line 111, external location: D:\android-ndk-r8e-windows-x86_64\android-ndk-r8e\sources\cxx-stl\gnu-libstdc++\4.6\include\future C/C++ Problem
source share