In my project I have turned on treat warnings as errors and compiling using the -pedantic
and -ansi
tags. I am using GCC compiler. In this project I have to use a third party source code which has got lot of warnings. Since I treat warnings as errors, I am having a tough time in fixing their code.
Most of the warnings are about invalid conversion from int
to size_t
or viceversa. In some cases, I won't be able to make both the variables same type, I mean I won't be able to change something to size_t
. In such cases I am doing an explicit cast. Something like,
size_t a = (size_t) atoi(val);
I am wondering is this the correct approach? Is there any problem in doing cast like this?
If these warnings are minor, can I suppress it only on their files? How do I do the same on MSVC?