如何在 clang 中禁用 -Wcompare-distinct-pointer-types 警告?

How can I disable -Wcompare-distinct-pointer-types warning in clang?

我遇到编译器错误,

comparison of distinct pointer types ('OrgApacheXpathObjectsXObject *' and 'OrgApacheXpathObjectsXNumber *') [-Werror,-Wcompare-distinct-pointer-types]

尝试使用 -Wno-incompatible-pointer-types 禁用它但没有帮助。 (-Wno-compare-distinct-pointer-types 甚至不是有效参数。)

在 GCC 上,显然没有办法禁用此警告,只是希望 Clang 在某种程度上更好?

我无法控制源代码。

-Wno-compare-distinct-pointer-types 确实有效。问题是,如果你在该行的其他地方有任何无效的编译器标志,那么整行都将是错误的,而不仅仅是一个错误的标志。

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
...
your code
...
#pragma clang diagnostic pop