0

My host OS is:

Fedora 22 x64

gcc-g++ version is:

5.1.1

eclipse cdt version:

Eclipse CDT Mars Release V4.5.0

here is my simple demo code list:

#include <thread>
void func(){}

int main(int argc, char** argv)
{
    std::thread ts(func);
    ts.join();
    return 0;
}

and this is my cdt config(wrong config):

Project Properties->C/C++Build->Tool Chain Editor->(use Linux GCC as current)
Project Properties->C/C++Build->Settings->GCC C++ Compiler->Dialet->(ISO C++11)
Project Properties->C/C++Build->Settings->GCC C Compiler->Dialet->(ISO C11)
Project Properties->C/C++Build->Settings->GCC C++ Linker->(add pthread)

Project Properties->C/C++General->Paths and Symbols->Symbols
->add '__GXX_EXPERIMENTAL_CXX0X__' to GNU C++

Project Properties->C/C++General->PreprocessorIncludePaths,Macros etc.->Providers
->(Select only 'CDT GCC Built-in Compiler Settings' and add'-std=c++11' to command)

the result is:

the project can build and run successfully
but eclipse CDT always show error: Symbol 'thread' could not be resolved
greg-449
  • 109,219
  • 232
  • 102
  • 145
usr
  • 1
  • 2
  • Maybe this will help: https://stackoverflow.com/questions/17131744/eclipse-cdt-indexer-does-not-know-c11-containers/24628885#24628885 – Galik Sep 02 '15 at 03:27
  • I already take the config of " __GXX_EXPERIMENTAL_CXX0X__ " but nothing help, this works fine on gcc v4.9 but take no effect on gcc5.1 tool chain. – usr Sep 02 '15 at 07:39
  • Look at the specific answer I linked to. – Galik Sep 02 '15 at 07:41

1 Answers1

0

The std::thread ts(func); might be considered as function definition. Use std::thread ts{func}; instead. Also threads needs -pthread setting for compiler/linker - like: g++ -std=c++11 -pthread prog.cpp.

KIIV
  • 3,534
  • 2
  • 18
  • 23
  • It works fine in terminal compile, I wanna solve the issue of -----> Eclipse CDT can not resolve std::thread symbol. – usr Sep 02 '15 at 06:54