News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[cleanup patch] Integer type usage in dataobj/einstellungen.h

Started by neroden, June 18, 2010, 08:21:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neroden

There are a number of unnecessary integer widening/shortenings going on which cause warnings with -Wconversion on recent GCC.  This eliminates some of them by using the correct type in set_ and get_ operations.  I updated and clarified some comments while I was at it.

I'm hoping to eventually be able to turn -Wconversion on permanently, as it warns about all kinds of dangerous data-losing operations, but it gives way too many warnings so far, so I'm having to clean them up a few at a time.

prissi

why casting (uint8)0 ??? 0u should also create an unsigned zero. (But since zero is unsigned anyway, this seems rather stupid of the compiler.)

neroden

Quote from: prissi on June 18, 2010, 09:24:11 PM
why casting (uint8)0 ??? 0u should also create an unsigned zero. (But since zero is unsigned anyway, this seems rather stupid of the compiler.)

It is rather stupid of the compiler.  This seemed to be the reliable way to prevent it from warning that I was narrowing an integer (32-bit zero versus 8-bit zero!).  It  should be smart enough to know that that is safe, but it seemed to be having trouble.