C ++ error "nullptr has not been declared in this area" in the Eclipse IDE

I am running Eclipse Helios and I have g ++ - 4.6 installed. I hope I'm not mistaken that g ++ 4.6 implements the features of C ++ 11. I created a C ++ project that uses the nullptr and auto keywords. The design gives the following errors: -

../{filename}.cpp:13:13: error: 'nullptr' was not declared in this scope ../{filename}.cpp:14:2: warning: 'auto' will change meaning in C++0x; please remove it [-Wc++0x-compat] 

In fact, it was built until yesterday. I get them out of nowhere today. Please help me solve this problem.

+42
c ++ eclipse-cdt g ++
Apr 05 2018-12-12T00:
source share
6 answers
Finally, it turned out what to do. Added -std = C ++ 0x compiler argument in the section "Project Properties" β†’ C / C ++ Build β†’ Settings β†’ GCC C ++ Compiler β†’ Miscellaneous. He is working now!

But how to add this flag by default for all projects in C ++? Is anyone

+16
Apr 6 '12 at 11:12
source share

According to the GCC page for C ++ 11 :

To enable C ++ 0x support, add the -std = C ++ 0x command line option to your g ++ command line. Or, to include GNU extensions in addition to C ++ 0x extensions, add -std = gnu ++ 0x to your g ++ command line. GCC 4.7 and later support -std = C ++ 11 and -std = gnu ++ 11.

Is compiled with -std=gnu++0x ?

+42
Apr 05 2018-12-12T00:
source share

Is this an actual compiler error or a code analysis error? Several times, code analysis can be a bit sketchy and report invalid errors.

To disable code analysis for a project, right-click on your project in the Project Explorer, click Properties, then go to the General tab C / C ++, then Code Analysis. Then click "Use Project Settings" and disable the ones you don’t want.

Also, are you sure you are compiling a C ++ 11 compiler?

+4
Apr 05 2018-12-12T00:
source share

Go to Settings β†’ Compiler ... And add the flag β€œHave g ++ follow the following C ++ 0x ISO C ++ standard [std = C ++ 0x]

+3
Dec 13 '15 at 0:48
source share

You are using g ++ 4.6, you must call the -std = C ++ 0x flag to compile

g ++ -std = C ++ 0x * .cpp -o output

0
Aug 11 '15 at 11:37
source share

I add ", -std = C ++ 0x" after "-c -fmessage-length = 0" in the "Project Properties" section β†’ C / C ++ Build β†’ Settings β†’ GCC C ++ Compiler β†’ Miscellaneous. Remember to add the comma "," as a separator.

0
Jul 09 '16 at 6:40
source share



All Articles