std::this_thread::sleep_for() and GCC

前端 未结 4 508
傲寒
傲寒 2020-12-02 22:21

When I try to compile this simple program:

#include

void f() {
  std::this_thread::sleep_for(std::chrono::seconds(3));
}

int main() {
  std::         


        
4条回答
  •  臣服心动
    2020-12-02 23:11

    Need to define _GLIBCXX_USE_NANOSLEEP on top of the source code.

    #define _GLIBCXX_USE_NANOSLEEP  //add it top of c++ code
    

    OR, Compile with following commamd:

    g++ a.cpp -o a -std=c++0x -D_GLIBCXX_USE_NANOSLEEP    //compile c++ code
    ./a       // run c++ code
    

提交回复
热议问题