Search code examples
c++gccpointersnull

error: ‘NULL’ was not declared in this scope


I get this message when compiling C++ on gcc 4.3

error: ‘NULL’ was not declared in this scope

It appears and disappears and I don't know why. Why?

Thanks.


Solution

  • NULL is not a keyword. It's an identifier defined in some standard headers. You can include

    #include <cstddef>
    

    To have it in scope, including some other basics, like std::size_t.