Eclipse CDT C++ NULL not resolved

删除回忆录丶 提交于 2019-12-11 08:26:56

问题


Related: Eclipse CDT "Symbol NULL could not be resolved"

I was under the impression that NULL was a standard macro in C++ and didn't need any headers to be included. Eclipse, on the other hand, thinks it doesn't exist.

Is there some way to remind Eclipse that I'm in C++ mode not C mode for this file, and therefore to shut up about the NULL problem?


回答1:


I was under the impression that NULL was a standard macro in C++.

It is, but it's not part of the language. You still need to include <cstddef> or <cstdlib>, etc.




回答2:


Why is NULL undeclared?

Quoted from the top-answer on that question.

NULL is not a built-in constant in the C or C++ languages. In fact, in C++ it's more or less obsolete, just use a plain literal 0 instead, the compiler will do the right thing depending on the context.

Otherwise, add

#include <stddef.h>

to get the NULL definition.

UPDATE: I had the wrong header, corrected now. Thanks! (Quoted from Unwind)



来源:https://stackoverflow.com/questions/10955343/eclipse-cdt-c-null-not-resolved

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!