guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing a struct within a struct


From: Ludovic Courtès
Subject: Re: Parsing a struct within a struct
Date: Thu, 10 Mar 2011 22:36:43 +0100
User-agent: Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux)

Hi Aidan,

Aidan Gauland <address@hidden> 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.  :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]