Cygwin struct alignment

John Emmas johne53@tiscali.co.uk
Wed Dec 24 12:17:00 GMT 2008


A program I'm building connects to a (Cygwin) server and receives the
address of a shared memory segment.  The memory contains an array of struct
and you probably know that Microsoft (by default) aligns structure members
on 8-byte boundaries (sometimes called 8-byte packing).

As things stand, both client and server use System V shared memory and
everything works well if I compile under Cygwin or Linux.  Ultimately
however, there'll be no Linux clients.  The clients will either be Cygwin
clients or Windows clients.  Therefore I'm currently experimenting to see if
I can change the server to use Windows shared memory (only under Cygwin of
course - not for Linux use).

This all seems to be going well - but I was surprised to find that I need to
compile the Windows clients using MSVC's default (8-byte) struct alignment.
I'd assumed that Cygwin probably wouldn't use structure packing (only
because I don't think Linux does).  But I only get meaningful data with
8-byte packing.  It looks as if Cygwin's compiler must default to 8-byte
packing too.  Does that make sense?

Thanks,

John 


--
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/



More information about the Cygwin mailing list