chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] C unions and structs, how to access them ?


From: felix winkelmann
Subject: Re: [Chicken-users] C unions and structs, how to access them ?
Date: Mon, 31 Oct 2005 07:57:04 +0100

On 10/30/05, Pupeno <address@hidden> wrote:
>
> So, when I try to wrap XNextEvent I end up with two procedures:
>
> (define x-next-event-raw
>    (foreign-lambda void "XNextEvent" display x-event))
>
> (define (x-next-event d)
>    (let ((e (foreign-value "malloc(sizeof(XEvent))" c-pointer)))
>       (x-next-event-raw d e)
>       e))
>
> Is that the right way to do it ? If not, how should I do it ?

This is fine, just make sure to free the malloced structure again.

>
> Now, the real question: How do I access XEvent's members and XEvent's members'
> members ?

You might also look into `define-foreign-record'.
The xlib egg uses accessor-procedures for each and every
structure member, which is ok, too (define-foreign-record does
essentially the same).


cheers,
felix




reply via email to

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