2

Use eclipse-cdt (latest version ) on Ubuntu. I create new project with one line code - mutex declarative.

compilation passed (compile with eclipse), but eclipse mark the mutex in red and complain on - 'mutex type could not be resolved'

i add ' -std=c++0x -pthread' to the g++ and refresh eclipse indexer, but didnt help.

Any advice?

#include <mutex>
using namespace std;

static mutex m;

int main(int argc, char *argv[]) {
}
Avihai Marchiano
  • 3,837
  • 3
  • 38
  • 55
  • possible duplicate of [Eclipse CDT C++11/C++0x support](http://stackoverflow.com/questions/9131763/eclipse-cdt-c11-c0x-support) – ecatmur Jul 30 '12 at 13:44
  • Does changing `-std=c++0x` to `-std=c++11` make any difference? Are you using the latest versions of Eclipse and GCC? – Mihai Todor Jul 30 '12 at 13:45
  • change to -std=c++11 dosnt work. compilation dosnt passed as well with this option. i am using latest version of eclipse. i asume the gcc ok , because build passed. – Avihai Marchiano Jul 30 '12 at 13:48

2 Answers2

4

C/C++ General -> Paths and Symbols -> Symbols -> GNU C++. Click "Add..." and paste __GXX_EXPERIMENTAL_CXX0X__ (ensure to append and prepend two underscores) into "Name" and leave "Value" blank.

This solve it.

Avihai Marchiano
  • 3,837
  • 3
  • 38
  • 55
  • 2
    The other option is to add the '--std=c++0x' (or c++11) to the eclipse discovery options, and then clear the discovery information. What eclipse does is run g++ with the options provided and captures a list of all of the symbols that are defined. – Dave S Jul 30 '12 at 16:52
  • I didn't understand the explanation on the discovery options? what is it the discovery option? why do i manage the g++ options in 2 palaces (i added it in the MISC )? why do i need to clear the discovery? Thank you!!!! it sound very interesting. – Avihai Marchiano Jul 30 '12 at 17:10
  • Under your project properties, type discovery into the search box. One of the things it should bring up 'C++ Build/Discovery Options' It lists both the command line options for discovery (where you should list '-std=c++0x') and a clear button which causes it to relearn the built in symbols defined by the compiler on your next build. – Dave S Jul 30 '12 at 17:19
  • I know where is it. My questions is what is it? why do i manage the g++ options in 2 places (i added it in the MISC )? why do i need to clear the discovery? – Avihai Marchiano Jul 30 '12 at 17:23
  • 1
    You don't HAVE to, it's another option to setting __GXX_EXPERIMENTAL_CXX0X__ manually. Basically, the first time you compile your project, Eclipse CDT (the C++ Developer Tools) runs the compiler with the options at the bottom of that page. It causes the compiler to output every compiler defined #define, so that the indexer knows which symbols have already been set. If you only add '-std=c++0x' to the misc options, then it doesn't use it for discovery and it isn't aware of `__GXX_EXPERIMENTAL_CXX0X__`. You have to set it the misc options regardless. – Dave S Jul 30 '12 at 17:26
1

-D__cplusplus=201103L helped me. Using Eclipse Luna. GXX_EXPERIMENTAL_CXX0X didn't help

Viktor
  • 392
  • 2
  • 8