[gameprogrammer] Re: problem filling a buffer
- From: Rasmus Toftdahl Olesen <halfdan@xxxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Thu, 22 Mar 2007 16:54:32 +0100
ons, 21 03 2007 kl. 16:23 -0500, skrev Roger D Vargas:
>
> Rasmus Toftdahl Olesen escribió:
>
> >
> > One thing that could ease filling a buffer i to just use a structure to
> > hold your data, and then pass a pointer to that as the buffer, e.g.:
> >
> > static const int COMMAND_LOGIN = 20;
> > static const int MAX_STRING = 10;
> > typedef struct {
> > int command;
> > char username[MAX_STRING];
> > char password[MAX_STRING];
> > } Login;
> Thanks for illustrating the use of SDLNet_Write. I will switch all my
> code to use it. But in this case, the compiler does not includes padding
> or something to align struct members?
The compilers i have come across all align members on byte boundaries,
and not character boundaries. I've recently seen code like this working
fine when communicating from an ARM processor (big-endian, ARM compiler)
to an Intel processor (MSVC compiler) over a USB connection.
I am sure there are some compilers that will align the members on 32-bit
boundaries, in which case you will experience strange errors. But
commonly it works fine.
--
Rasmus Toftdahl Olesen <halfdan@xxxxxxxxxxxx>
halfdans.net
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] problem filling a buffer
- From: Roger D Vargas
- [gameprogrammer] Re: problem filling a buffer
- From: Rasmus Toftdahl Olesen
- [gameprogrammer] Re: problem filling a buffer
- From: Roger D Vargas
Other related posts:
- » [gameprogrammer] problem filling a buffer
- » [gameprogrammer] Re: problem filling a buffer
- » [gameprogrammer] Re: problem filling a buffer
- » [gameprogrammer] Re: problem filling a buffer
- [gameprogrammer] problem filling a buffer
- From: Roger D Vargas
- [gameprogrammer] Re: problem filling a buffer
- From: Rasmus Toftdahl Olesen
- [gameprogrammer] Re: problem filling a buffer
- From: Roger D Vargas