错误:未在此范围内声明“NULL"

2022-01-06 00:00:00 gcc pointers null c++

在 gcc 4.3 上编译 C++ 时收到此消息

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?

谢谢.

推荐答案

NULL 不是关键字.它是一些标准头文件中定义的标识符.你可以包括

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

#include <cstddef>

将其纳入范围,包括一些其他基础知识,例如 std::size_t.

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

相关文章