X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BARRACUDA_BRBL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <495291CD.1000207@bmts.com> Date: Wed, 24 Dec 2008 14:47:25 -0500 From: Ralph Hempel User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Cygwin struct alignment References: <006b01c965c1$6a7c6300$4001a8c0 AT mycomputer> <003a01c965fe$539063c0$4001a8c0 AT mycomputer> In-Reply-To: <003a01c965fe$539063c0$4001a8c0@mycomputer> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-brucetelecom.com-MailScanner-Information: Please contact Bruce Telecom 519.368.2000 for more information X-brucetelecom.com-MailScanner: Found to be clean X-brucetelecom.com-MailScanner-From: rhempel AT bmts DOT com X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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.. > 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 > 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: 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/