[plt-scheme] Questions about modules, compilation, namespaces, planet and ffi

From: Eli Barzilay (eli at barzilay.org)
Date: Mon May 2 15:18:17 EDT 2005

On May  2, Bruno Deferrari wrote:
> It's me again, I have a new question about the ffi.
> How do I manage unions and struct bitfields??
> 
> For example:
> 
> struct A {
>   int field1 : 1;
>   int field2 : 1;
>   union {
>      int i;
>      char c[4];
>   };
> };
> 
> Well, I'm going to look at the sourcecode anyway, maybe I can find
> the solution there.

There is no built-in way to deal with both of these, since libffi
doesn't have any.  We have experimented with both though -- for bit
fields, see the _sf-format in collects/ffi/sndfile which does
something similar, and for unions, you simply take the maximum size
and alignment and generate a type that has these, then reference it as
any of the other types.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



Posted on the users mailing list.