[SDL] little endian and big endian

Leonardo Guilherme leonardo.guilherme at gmail.com
Tue Apr 7 06:44:44 PDT 2009


Actually big endian and little endian is not an OS feature, but a processor
architeture one (I'm not completely sure about this, somebody know any OS
that control the endianess?). That means you don't need to be aware of
endianess, but you must be aware of data sizes (OSes can have control about
this, it might change from one to the next).

Like Albert said, if you are doing normal operations on the variables you're
using (like a = b, a and b being int), you should'nt have problems, but if
you are working on the raw data, never assume the size of anything you
have'nt made yourself.

Making wrappers around those types you have'nt made usually is a good idea,
or using some sizeof operator...

2009/4/7 Albert Zeyer <albert.zeyer at rwth-aachen.de>

>
> 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,
>> FRAN
>>
>>
>
> 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.
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090407/9e629600/attachment-0008.htm>


More information about the SDL mailing list