On Mar 27, 2005, at 3:20 PM, Miles Gazic wrote:
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
Excellent point however a responsable programmer can take this into account
when designing the data structures and account for this. Again I point out the
myriad of image formats that demonstrate that you can successfully pass
structures over the Net.
Cheers
Norman
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Norman Vine 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 creator.
Cheers
Norman
_______________________________________________ Flightgear-devel mailing list [email protected] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
_______________________________________________ Flightgear-devel mailing list [email protected] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
_______________________________________________ Flightgear-devel mailing list [email protected] http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
