0

When using g++ to compile the .cpp file, I got the error like this :

  xx.cpp:25:5: error:'nullptr' was not declared in this scope.
  # the error is translated by me :)

The 'nullptr' is added just in C++11. I guess the default version in g++ may be the old version, so g++ can not recognize 'nullptr'. (My g++ version is 4.6.3) Instead, I added -std=c++0x before the .cpp file, but it still not worked. Then I seeked in the gcc manual,only find nothing relevant to the trouble.

Therefore, I hope someone here can answer my question, thank for any help.

罗泽轩
  • 1,603
  • 2
  • 14
  • 19
  • http://stackoverflow.com/questions/10363646/compiling-c11-with-g – qwr Jul 06 '13 at 15:26
  • According to the list of features, gcc 4.6.3 should support nullptr: http://gcc.gnu.org/gcc-4.6/cxx0x_status.html Can you post both your command line and the line of code that shows this error? – Timo Geusch Jul 06 '13 at 15:28

1 Answers1

1

If nullptr is only recognised in C++11, why would you compile with C++0x?

Use -std=c++11 when you compile: g++ -std=c++11 xx.cpp