Sign in to follow this  
bapti

Confusing warning

Recommended Posts

bapti    122
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

Share this post


Link to post
Share on other sites
pinacolada    834
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.

Share this post


Link to post
Share on other sites
SirKnight    316
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this