在visual studio中,如果您有最高警告级别,您将收到有关向下转换变量的警告。如:
warning C4244: '=' : conversion from 'x' to 'y', possible loss of data
我目前在一组相当大的代码中更改了一些数据类型。它现在正在成功编译。问题是我假设代码库中存在大量不再需要的强制转换。
总之,无论如何都要让Visual Studio报告不必要的演员表吗?如:
long foo = 10;
long bar = static_cast<long>(foo);
也许就是这样的。
Cast from type long to long is unnecessary. They are already the same type.