VOGONS


First post, by TeaRex

User metadata
Rank Member
Rank
Member

VC++ 2010 SP1 gives compiler warnings when you stuff anything >32767 into a signed short, including hex numbers; new mouse.cpp does just that in lines 590, 598 and 613.

Change Bit16s to Bit16u in line 128?

tearex

Reply 1 of 8, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Old mouse.cpp does this in line 629; what's the difference? More warnings now than before? The granularity mask is Bit16s to not mix types with the coordinates it's ANDed with. Maybe use -1, -2, -8, and -16 constants instead of 0xffff, 0xfffe, 0xfff8, and 0xfff0...?

Reply 2 of 8, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

isn't there some character that we can add to it ? (like with the long numbers)

Water flows down the stream
How to ask questions the smart way!

Reply 5 of 8, by TeaRex

User metadata
Rank Member
Rank
Member

@wd: Thanks for being able to look inside my head. Obviously I read through the code and looked at all uses of the bit mask variables in question, before making my suggestion. Unless I'm quite mistaken, they are only ever set to constants and used in bitwise logical operations with other values. No arithmetics are done on them. Therefore please excuse me for saying that you shouldn't call my suggestion "random" without even knowing what I thought. Call it the wrong solution, call it unnecessary, call it badly argued if you want. Random it is not. I know that you don't like to be pissed off by unreasonable posts on this forum, and neither do I.

@ripsaw: The old code didn't give any warnings, maybe the ternary operator prevented it for some arcane reason, but of course you are right it's basically the same. Is there any kind of problem with mixing signed and unsigned in bitwise logical (as opposed to arithmetic or comparative) expressions?

@Qbix I think there is only "u", "l", "ul", "ll", and "ull" postfixes for making constants "longer" types than they would naturally be. Nothing for making things "short" or "signed".

@all of course this is only about a bunch of compiler warnings so nothing exactly of world shattering importance. My point wasn't to complain or annoy people but just to notify you in case you should want to avoid compiler warnings, since I don't know if any of the main developers do regular builds with Visual Studio.

tearex

Reply 6 of 8, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author
TeaRex wrote:

Is there any kind of problem with mixing signed and unsigned in bitwise logical (as opposed to arithmetic or comparative) expressions?

Maybe it's not a problem; I'm just not certain if the result is signed or unsigned, and it needs to be signed. Could put a (Bit16s) typecast around the whole expression in the POS_X and POS_Y defines to be certain, but it seemed easiest to use identical types, and GCC didn't complain.

Does an explicit typecast on the constants like "mouse.gran_x=(Bit16s)0xfffe;" prevent the compiler warnings?

You can disable warnings in VC++ with "#pragma warning( disable : nnnn )" where nnnn is the warning number, but I don't know if compiler-specific directives like this are put in official source.

Reply 7 of 8, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Therefore please excuse me for saying that you shouldn't call my suggestion "random" without even knowing what I thought.

I don't see any justification for the signedness change besides "it fixes a warning". That's random.
Nevertheless it may be the correct thing to do of course, I didn't check. If it is, the warning was
correct in the first place. Otherwise if the target bitsize is verified you can use a C-cast or
(Qbix likes them more) static/dynamic casts.

since I don't know if any of the main developers do regular builds with Visual Studio.

Certianly not on a daily basis.