对 C++ 空指针使用 NULL 或 nullptr?

Mar*_*c-O 0 c++ null clang

我正在尝试在虚拟测试文件上制作一些 Clang AST 转储。这是我正在使用的命令行:

 clang -Xclang -ast-dump -fsyntax-only test.cpp
Run Code Online (Sandbox Code Playgroud)

int * a = NULL;可以被我的 test.c 识别,但不能被我的 test.cpp 识别。

我也尝试过int * a = nullptr;,但这也不起作用。

我应该更改命令行中的一些选项吗?

cod*_*ddy 5

使用此命令行: clang -std=c++11 -Xclang -ast-dump -fsyntax-only test.cpp

现在你可以使用nullptr

或者

#include <cstddef>
Run Code Online (Sandbox Code Playgroud)

现在你可以使用NULL

否则使用0