[CF-Devel] Patch: some warning cleaning under Win32
crossfire-devel at archives.real-time.com
crossfire-devel at archives.real-time.com
Tue Dec 9 23:44:30 CST 2003
Nicolas Weeger wrote:
>
Here's another patch to remove some compilation warnings (for Win32 at
>
least).
>
(note: this patch completes and replaces the previous one)
please don't compress/gzip/whatever small attachments - it makes it harder to
just quickly browse the change.
>
>
Core of changes is type fixing. When a socket function was used to write
>
data, I either explicitly casted the argument(s) to the matching type
>
(ie SockList_AddChar( &sl, ( char )x ) where x is an int) or fixed the
>
argument's type by changing its definition (ie changing int x to char x).
>
Also fixed a few signed/unsigned mismatches.
>
>
I also changed the sounds functions prototypes, 'cause x, y (relative
>
coordinates) are sent as char anyway so no need to give int, same for
>
soundnum (int sent as short)
Changing any data type to 'char' is sure to cause problems.
This is because I don't believe the data type of 'char' is defined as either
signed or unsigned. That is to say on some systems, this may be a signed value,
while on other systems, it would be an unsigned value.
Thus, in the case where you mention in sound play, that may break things on
systems where chars are unsigned (passing in -1 will not result in the value you
want). So basic moral is never use 'char' for anything but strings. Use the
uint8/sint8 types instead.
This applies to other code where you've changed some other type to a char.
I'm considered about the stat code, as another example. Many of the stat
numbers are now above 127 - assigning those a value greater than 127 may not
have the desired effects.
_______________________________________________
crossfire-devel mailing list
crossfire-devel at lists.real-time.com
https://mailman.real-time.com/mailman/listinfo/crossfire-devel
More information about the crossfire
mailing list