I std::asyn
Funktion praktiziert, die in C++ 11 eingeführt, habe ich ein einfaches Beispielcoudn't run-Code verwendet std :: async auf GCC 5.3.0
#include<future>
#include<iostream>
using namespace std;
void check()
{
cout<<"some"<<endl;
}
int main()
{
auto p=std::async(std::launch::async,check);
p.get();
}
schrieb ja sehr einfach, mit zu beginnen, und ich bin Kompilieren GCC 5.3.0
g++ -std=c++11 practise.cpp -lpthread
und den Fehler
practise.cpp: In function 'int main()':
practise.cpp:13:47: error: invalid use of incomplete type 'class std::future<int>'
auto p=std::async(std::launch::async,chech);
^
In file included from practise.cpp:1:0:
C:/Program Files/mingw32/i686-w64-mingw32/include/c++/future:115:11: note: declaration of 'class std::future<int>'
class future;
^
Fehle ich etwas? ist die Art, wie ich lpthread verlinkt ist ok? Ich bin auf Windows 7.
ausführen "https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.3 .0/threads-posix/seh/"das könnte das richtige Paket für mich sein –
Ich habe den Online Installer von hier aus benutzt: https://sourceforge.net/projects/mingw-w64/. – marcinj