[SDL] little endian and big endian

Albert Zeyer albert.zeyer at rwth-aachen.de
Tue Apr 7 06:35:49 PDT 2009

Am 07.04.2009 um 15:28 schrieb Francisco Bodego Franco:

> Hi everybody!!!
> I have one doubt about little endian and big endian issue.
> I want to develop one game for windows, linux and MacOS, can I use  
> the int,
> bool, char and String literals normally? Or I have to create new  
> classes
> that simulate this literals?
> Thanks for all,

Depends what you are doing. For all normal operations, you should not  
see a difference.

When you are manipulation/accessing the raw data behind, e.g.:

Uint32 color = SDL_MapColor(/*...*/);
uchar *px = surface->pixels;

memcpy(px, (uchar*)&color, surface->format->BytesPerPixel);

That won't work.

Also fwrite/fread will not work directly. Best is to code some small  
wrappers around those.

More information about the SDL mailing list