I am trying to compile this code in Windows 8 using Eclipse Luna. I get the error: 'thread' is not a member of 'std'
#include <thread>
#include <iostream>
void func() {
std::cout << "Hello thread!" << std::endl;
}
int main() {
std::thread t(func);
t.join();
return 0;
}
I used Eclipse MinGW, GCC and Eclipse CygWin, GCC. I used the settings: -pthread -std=c++11 C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags However the error remains. I looked into the sources of thread.h. There I found the line
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
I defined _GLIBCXX_HAS_GTHREADS
and _GLIBCXX_USE_C99_STDINT_TR1
in C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Preprocessor -> Defined symbols. This makes the compile error disappear but I get a bunch of other errors which appear to come out from system libraries. Anyway: defining the symbols looks more like a "hack" than the "official" and recommended solution
By the way: I tried also with Code::Blocks instead of Eclipse but I got the same error.
Aucun commentaire:
Enregistrer un commentaire