Back to Programming techniques
When a compiler emits a warning, it might or might not mean that changes are warranted in the code itself. While most of the warnings are appropriate, some are not, and further, to some warnings there are no practical solutions. In these cases, instead of modifying your code, disabling the warnings is the right thing to do. Here we list all the warnings we have disabled in Pastel, and explain why we have done that.
For int a = 1.0f;
, the warning refers to a floating point type being converted to an integer type. It is self-evident that there is possible loss of data when doing the conversion, and this is most of the time also the intention (rounding). This warning essentially urges to use a cast to make the conversion explicit to the reader. From the compilers view, this cast is redundant, since the implicit conversion will take effect in any case, and can be seen as a case-by-case supression of the warning. We find the redundant casts making the code less clear, and thus disable the warning instead. At a later time, if desired, the compiler can help to locate these places by enabling the warning.
For long long c = 1; int b = c;
, the warning is more to the point. However, since we use the integer
type exclusively to store amounts, this is not a problem. See the explanation for the warning 4267 below to see why this is.
that >= 0
is always true for an unsigned integer.