Начал знакомиться с потоками и при первой же попытке это "пощупать" словил ошибку:
(Compiler GCC 8.2.0)
Imagine.cpp: In function 'void foo()':
Imagine.cpp:6:10: error: 'std::this_thread' has not been declared
std::this_thread::sleep_for(std::chrono::milliseconds(4000));
^~~~~~~~~~~
Imagine.cpp: In function 'int main()':
Imagine.cpp:11:10: error: 'thread' is not a member of 'std'
std::thread test(foo);
^~~~~~
Imagine.cpp:11:10: note: 'std::thread' is defined in header '<thread>'; did you forget to '#include <thread>'?
Imagine.cpp:3:1:
+#include <thread>
#include <chrono>
Imagine.cpp:11:10:
std::thread test(foo);
^~~~~~
Imagine.cpp:13:5: error: 'test' was not declared in this scope
test.join();
^~~~
Imagine.cpp:13:5: note: suggested alternative: 'tzset'
test.join();
^~~~
tzset
Сам код:
#include <iostream>
#include <thread>
#include <chrono>
void foo(){
std::cout<<"Thread"<<std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(4000));
std::cout<<"END"<<std::endl;
}
int main(){
std::thread test(foo);
test.join();
return 0;
}
Дело в том, что онлайн компиляторы ошибок не выдают.
Вопрос: С чем может быть связано то, что у меня не находит библиотеку ? Я проверил: она лежит в путях компилятора, но все равно выхлоп нулевой!