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

David Olofson david.olofson at reologica.se
Mon Aug 27 13:41:00 PDT 2001


On Monday 27 August 2001 21:54, Kylotan wrote:
> > > res = (int)r;
> > > res |= (int)g << 8;
> > > res |= (int)b << 16;
> >
> > Integer promotion rules make these casts redundant.  Replace 'int'
>
> with
>
> > '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?

AFAIK, they're mandatory, and most compilers follow them.

However, "promotion to int" means "promotion to whatever size int is on 
this platform", so it might not do what you want even if the compiler 
doesn't do anything wrong - that's the problem here.


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> david at linuxdj.com -'




More information about the SDL mailing list