This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin struct alignment


John Emmas wrote:

Actually, this is turning out to be slightly more complicated than
I thought.  Member alignment for very simple structs seems to correlate
pretty well but more complex structs cause subtle (though hopefully not
insurmountable) problems..

<snip>


Is it possible (in Cygwin) to disable structure packing? (I know this is
possible for MSVC). Also, is there a handy reference where I could find out more about the format and 'size' of basic Cygwin types? Most of them are
obvious of course, but there are a few less obvious ones, l

<snip>


Anywhere I can find out this kind of stuff??

John, if I understand you correctly, you are running up against a classic problem in embedded systems programming. Namely that you cannot assume anything about structure packing, byte ordering, or alignment when doing RPC or transmitting data across platforms.

The most general solution is a structure definition language and
an agnostic data format for the transmission. You'll need to
provide packing and unpacking routines on each end that understand
what type of structures you're dealing with.

Here's a reference to this problem and a solution:

<http://www.faqs.org/rfcs/rfc1832.html>

I've run into this many times, and have solved the problem this way
every time. You can try to bludgeon your compiler into doing the
right thing, but there will be mysterious problems when someone
else wants to use your system and does not have their settings
right.

Good luck!

Ralph




-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]