在使用std::async
的GCC 4.7.2(在cygwin上,compiled from source)上失败
error: invalid use of incomplete type
某些std::__async_sfinae_helper
的。我运气不好,感谢你的帮助。
#include <future>
int main()
{
std::async([]{});
}
失败
g++ -Wall -pedantic -std=c++0x future.cpp -o future
future.cpp: In function 'int main()':
future.cpp:5:22: error: invalid use of incomplete type 'std::__async_sfinae_helper<main()::<lambda()>, main()::<lambda()> >::type {aka class std::future<void>}'
In file included from future.cpp:1:0:
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future:111:11: error: declaration of 'std::__async_sfinae_helper<main()::<lambda()>, main()::<lambda()> >::type {aka class std::future<void>}'
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future: At global scope:
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future:187:5: error: 'typename std::__async_sfinae_helper<typename std::decay<_Func>::type, _Fn, _Args ...>::type std::async(_Fn&&, _Args&& ...) [with _Fn = main()::<lambda()>; _Args = {}; typename std::__async_sfinae_helper<typename std::decay<_Func>::type, _Fn, _Args ...>::type = std::future<void>]', declared using local type 'main()::<lambda()>', is used but never defined [-fpermissive]
<builtin>: recipe for target `future' failed
版本信息
% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-cygwin/4.7.2/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++
Thread model: single
gcc version 4.7.2 (GCC)
c++11 std::async doesn't work in mingw没有帮助,因为我既不使用mingw,也不是线程模型win32。