18

我尝试使用 std::this_thread::sleep_for() 函数但得到了错误
error: 'std::this_thread' has not been declared
标志 _GLIBCXX_USE_NANOSLEEP 包括在内。
还需要什么来强制它工作?
MinGW ==> gcc 版本 4.7.2 (GCC)

SSCCE:

#include<thread>

int main() {
  std::this_thread::sleep_for(std::chrono::seconds(3));
}

命令行:

g++ -D_GLIBCXX_USE_NANOSLEEP -std=gnu++0x ssce.cpp -o ssce.exe

编译结果:

ssce.cpp: In function 'int main()':
ssce.cpp:4:8: error: 'std::this_thread' has not been declared
4

1 回答 1

11

使用带有 POSIX 线程的 MinGW,Luke。

http://sourceforge.net/projects/mingwbuilds/

于 2012-12-09T08:29:40.287 回答