From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Parsing a struct within a struct Date: Thu, 10 Mar 2011 22:36:43 +0100 Message-ID: <8739mu64k4.fsf@gnu.org> References: <20110308072028.GA11631@neko> <20110309082419.GA6429@neko> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1299793032 27947 80.91.229.12 (10 Mar 2011 21:37:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2011 21:37:12 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Mar 10 22:37:08 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PxnXe-0005ww-K1 for guile-user@m.gmane.org; Thu, 10 Mar 2011 22:37:06 +0100 Original-Received: from localhost ([127.0.0.1]:36050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PxnXd-0003aZ-TL for guile-user@m.gmane.org; Thu, 10 Mar 2011 16:37:05 -0500 Original-Received: from [140.186.70.92] (port=46498 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PxnXX-0003Yp-5b for guile-user@gnu.org; Thu, 10 Mar 2011 16:37:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PxnXV-0007OQ-Vp for guile-user@gnu.org; Thu, 10 Mar 2011 16:36:59 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:42373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PxnXV-0007OF-QY for guile-user@gnu.org; Thu, 10 Mar 2011 16:36:57 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PxnXU-0005ru-6e for guile-user@gnu.org; Thu, 10 Mar 2011 22:36:56 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Mar 2011 22:36:56 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Mar 2011 22:36:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 20 =?iso-8859-1?Q?Vent=F4se?= an 219 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:MZljTgKmYzLciKLviYEjhnxaWow= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8524 Archived-At: Hi Aidan, Aidan Gauland writes: > On Tue, Mar 08, 2011 at 08:20:29PM +1300, Aidan Gauland wrote: >> (parse-c-struct event-pointer >> (list uint8 uint8 uint8 >> (list uint8 int int uint16 ))) >> > > It seemed to be an off-by-one(-byte) error. There was padding to > align (to 32-bits, I think) the sub-struct. > > This works on my 32-bit machine, but I suspect it is not portable. > > (parse-c-struct event-pointer > (list uint8 uint8 uint8 uint8 ; Padding > (list uint8 int int uint16 ))) > > What would be a better, portable solution? I suspect the `alignof' > procedure is my friend here, but I don't understand how to use it. The ‘alignof’ procedure was actually your enemy here. ;-) This patch should fix it (will be in 2.0.1): http://git.savannah.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=d82f8518b96bbfa4f29e03d922369c37b64824d9 Thanks! Ludo’. PS: Let us know when your game is ready. :-)