哪一个Clang警告等效于GCC中的Wzero-as-null-pointer-constant? [英] Which Clang warning is equivalent to Wzero-as-null-pointer-constant from GCC?
问题描述
我们的项目使用C ++ 11/14,我们想使用 nullptr
代替带有指针的 0
或 NULL
,即使在允许 0
(作为整数文字).
Our project uses C++11/14, and we want to use nullptr
instead of 0
or NULL
with pointers, even when 0
(as an integer literal) is allowed.
我有以下代码:
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
的任何警告.
If I compile with GCC (5.3.0) and the flag -Wzero-as-null-pointer-constant
it warnings in #2
, but I can't find a similar flag in Clang. If I compile the code with Clang (3.7.1) and the flag -Weverything
, I don't get any warning about #2
.
那么,在Clang中有没有办法得到类似的警告?
So, is there any way to get a similar warning for this in Clang?
推荐答案
Clang不支持此类警告(即,在其中没有 -Wzero-as-null-pointer-constant
等效项)铛).如果添加 -Weverything
选项(请注意仅在测试时这样做),即可启用所有Clang的警告.
Clang doesn't support these kind of warnings (i.e., there's no -Wzero-as-null-pointer-constant
equivalent in Clang). You can see it your self if you add -Weverything
option (mind do it only for testing), which enables all Clang's warnings.
这篇关于哪一个Clang警告等效于GCC中的Wzero-as-null-pointer-constant?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!