Reputation: 3859
I have the below code which gives the error mentioned in the title. It is a cut down version of the sample available here:
#include <thread>
#include <future>
int main()
{
std::packaged_task<int()> task([] {return 1;});
return 0;
}
However, thought that being as I was specifying the type of the package task as int() as specified in another answer here then it would be correctly resolved but it is not.
Can anyone spot what I have done wrong?
Upvotes: 3
Views: 687
Reputation: 1095
try:
g++ -E x.cpp > output.txt
It will run the preprocessor so you can see what the compiler is getting.
If I run it from cygwin, only the predeclaration of std::packaged_task
is present in the output, but not the definition. The future
file contains the following preprocessor condition:
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
&& defined(_GLIBCXX_ATOMIC_BUILTINS_4)
and in my cygwin installation, the macro _GLIBCXX_HAS_GTHREADS
is not defined, so everything inside the #if
is removed. Perhaps the same happens to you.
Upvotes: 1