gpt4 book ai didi

c++ - 哪个 Clang 警告等同于 GCC 的 Wzero-as-null-pointer-constant?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:23:40 26 4
gpt4 key购买 nike

我们的项目使用 C++11/14,我们希望使用 nullptr 而不是 0NULL 指针,即使0(作为整数文字)是允许的。

我有以下代码:

int main()
{
int *ptr1 = nullptr; // #1
int *ptr2 = 0; // #2
}

如果我使用 GCC (5.3.0) 和标记 -Wzero-as-null-pointer-constant 进行编译,它会在 #2 中发出警告,但我可以'在 Clang 中找不到类似的标志。如果我使用 Clang (3.7.1) 和标志 -Weverything 编译代码,我不会收到任何关于 #2 的警告。

那么,有什么办法可以在 Clang 中得到类似的警告吗?

最佳答案

从 5.0 开始,clang 有这个警告;我加了here .

关于c++ - 哪个 Clang 警告等同于 GCC 的 Wzero-as-null-pointer-constant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34953361/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com