I have the below code which gives the error mentioned in the title. It is a cut down version of the sample available here:
cppreference
#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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With