如何禁用 CMAKE 中的隐式转换更改符号警告
有人知道是否有办法禁用 CMAKE 中 clang 发出的这种警告吗?
std::vector<float> v{1.f, 2.f, 1.f};
int i = 1;
float foo = v[i]; // Here we get the warning, variable i should be a size_t
...
Implicit conversion changes signedness: 'int' to 'std::__1::vector<float>::size_type' (aka 'unsigned long')
Clang 编译器向我发出有关 v[i]
的警告,因为它希望我将其转换为 size_t
,如果我在任何地方都进行显式转换,这将非常冗长。
另外,我不想使用 size_t
。对我来说,这种类型很容易出错,因为在得到负结果时它会破坏标准减法。 (顺便说一句,我的向量永远不会超过 2^31)
Does anybody know if there is a way to disable this kind of warning given by clang in CMAKE please ?
std::vector<float> v{1.f, 2.f, 1.f};
int i = 1;
float foo = v[i]; // Here we get the warning, variable i should be a size_t
...
Implicit conversion changes signedness: 'int' to 'std::__1::vector<float>::size_type' (aka 'unsigned long')
Clang compiler gives me a warning on v[i]
as it wants me to cast it as a size_t
which is quite verbose if I do explicit casting everywhere.
Also, I don't want to use size_t
. For me this type it is error prone as it breaks the standard substraction when getting negative results. (my vectors will never exceed 2^31 btw)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论