[SDL] Get pixel value ...more in details

Kylotan kylotan at kylotan.eidosnet.co.uk
Mon Aug 27 13:04:01 PDT 2001

> > res = (int)r;
> > res |= (int)g << 8;
> > res |= (int)b << 16;
> Integer promotion rules make these casts redundant.  Replace 'int'
> 'Uint32', and they'll be correct and no longer redundant.

Are these rules mandated by the Standard (and if so, is it the same for
C and C++), or are they just something that 'most' compilers do?
Personally I don't see why the left value in a shift expression would be
promoted to the type of the value on the right. It makes sense for
arithmetic operators but not for shift operators. For example, where's
the sense in having ((char)100 << (long)14) and ((char)100 << (short)14)
yielding different results?

Ben Sizer

More information about the SDL mailing list