Hi,<br><br>I am trying to convert an FFI cstruct definition into a union.<br>More exactly, the previous definition was :<br>(define-cstruct _XEvent<br> ((type EventType)))<br><br>with EventType being defined elsewhere.<br>
But this was an incomplete definition, and I now want to translate the following C union:<br>typedef union _XEvent {<br> int type; /* must not be changed; first element */<br> XAnyEvent xany;<br> XKeyEvent xkey;<br>
// ... the rest for later<br>} XEvent;<br><br>I searched the collects directory, but I see only a single and too simple _union use, so I'm not sure how to use it. <br>I guessed the following:<br> (define _XEvent<br>
(_union EventType ; type<br> _XAnyEvent ; xany<br> _XKeyEvent ; xkey<br> ; etc.<br> ))<br> (define (XEvent-type ev) (union-ref ev 0))<br> (define (XEvent-xany ev) (union-ref ev 1))<br>
(define (XEvent-xkey ev) (union-ref ev 2))<br><br>However, now I don't use define-cstruct anymore (it would not work with _union, would it?), so I don't have all the -tag, -pointer, etc. bindings, which I need.<br>
<br>What should I do ?<br><br>Thanks,<br>Laurent<br><br>