Confusing warning

Started by
2 comments, last by SirKnight 19 years, 2 months ago
I'm writing a game with OpenGL, c++ and on Windows. I keep getting the warning below and I can't figure out what's causing it. Could someone gimme a clue as to what i've done wrong or what I should be looking for. The game is currently working but the warning pops up with every build. warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data Cheers N
Advertisement
The warning occurs because WPARAM is apparently a bigger data size than int, so it's warning you that you might be losing data.

The quick-and-easy way to make it stop giving the warning is to do an explicit cast, so change this:

return whateverItIs;

to this:

return (int) whateverItIs;

The "correct" way is probably to change the function declaration so that it returns WPARAM instead of int, so there's no chance of data being lost (at least, not at that step)

Personally I would do the quick-and-easy fix.
cheers, will give that a try
Double click on the warning line and you will be taken directly to the line of code that is causing this warning. I'm guessing this is comming from the return line in your windows procedure function. The compiler is just warning you that the cast conversion from a WPARAM type to an int type may result in the loss of data because the number of bits allocated with a WPARAM and int may not be the same (or there is an unsigned/signed difference). Chances are they are the same though. You can pretty much just ignore this.

It turns out that a WPARAM is really a UINT_PTR type which is just an unsigned int. So the compiler is seeing an unsigned int to signed int conversion cast which could (but not always) give you a value you don't want.


-SirKnight

This topic is closed to new replies.

Advertisement