nullptr not declared in scopt WITH c++11 support

1.2k views Asked by At

I have installed: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

As IDE I use either eclipse CDT or Code::Blocks, does not matter which one. I will stick to Code::Blocks for now. If i use a null pointer in my code I get: nullptr was not declared in this scope

All research related cross postings just say, if compiler supports C++11 (Version 4.8.2 should do), add

-std=c++11 

as parameter. I have done it in both IDE does not turn of the error message. In CodeBlocks this is done by settings -> compiler (Gnu GCC Compiler is selected) and checking: Have g++ follow the C++11 ISO C++ language standard

Still I got the error message.

1

There are 1 answers

0
Sid Sarasvati On

I had similar issue with gcc 4.8.2 when using nullptr and compiling with -std=c++11 flag.

It turns out I had -ansi flag appearing after -std=c++11 which made gcc using ansi compiler option and silently ignoring -std=c++11. Removing the ansi flag or any other conflicting -std flags, like -std=c90 or -std=iso9899:1990, would do the trick.