Don't ever assume that all the components of a structure will be at the
same location within the struct on all architectures, or that the
structure size will be the same.  Processor architecture, language used,
compiler, and compiler flags all can change how a structure is packed.

That usually means that when an element of your structure is less than
the word size of the machine, it'll start the next element of the
structure at the next word boundary.  So if you have a char followed by
an int on a 32 bit machine, your compiler can decide to put the int 3
bytes after the char, instead of immediately following it.  Sometimes
you can change how things are packed by using compiler specific pragmas.
Sometimes you cannot.

- Miles

-----Original Message-----
[mailto:[EMAIL PROTECTED] On Behalf Of Norman
Sent: Sunday, March 27, 2005 9:29 AM
To: FlightGear developers discussions
Subject: RE: [Flightgear-devel] net_fdm.hxx net_ctrls.hxx

Paul Kahler writes:
> Never block transfer a structure by providing a pointer and size, 
> there is simply no way for that to work cross-platform.

Please ....

That this isn't true is amply demonstrated by all the images that get
passed around the net :-) 

All one needs to do is make sure that the endian order of the data is
well defined !

There are many ways to do this perhaps the easiest is to just use a
'magic' cookie at the beginning of the data structure *or* have a well
defined structure that insures a certain endian order is imposed on the



Flightgear-devel mailing list

Flightgear-devel mailing list

Reply via email to