Advertisement

comparison between signed and unsigned integer

Started by June 17, 2015 07:10 AM
1 comment, last by L. Spiro 9 years, 6 months ago

Hi

how to avoid the warning:

warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Thanks in advance

GLuint bytesPerPixel; // Holds Number Of Bytes Per Pixel Used In The TGA File
GLuint imageSize; // Used To Store The Image Size When Setting Aside Ram

...

for(GLuint i=0; i<int(imageSize); i+=bytesPerPixel) // Loop Through The Image Data

You explicitly force the compiler to convert a GLuint into an int and then compare it to another GLuint. Not only is the cast completely pointless, it is also the source of your warning.

Edit: also, if you need to cast get into the habit of using proper C++ casts like static_cast or reinterpret_cast, not pure C casts which do not convey any intent and are difficult to find.
Advertisement

for(GLuint i=0; i<imageSize; i+=bytesPerPixel)

As said above, you added unnecessary code that created the warning. It doesn’t make sense.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement