Value -Werror = vintage?

I use code that makes some ints float for division.

size_t a;
uint8_t b, c;

a = (float)b / (float)c;

I compiled with warning flags turned on, and I got one for the "old throw". Is there a better or correct way that I should throw these things? If so, how?

+4
source share
1 answer

Old styles in the style of "C-style." -Werror=old-style-castturns the use of C-style into errors. You should use C ++ cast .

Here you can use static_cast:

size_t a; uint8_t b, c;

a = static_cast<float>(b) / static_cast<float>(c);
+7
source

All Articles