[racket] FFI bitfields
At Sun, 09 Jun 2013 21:42:47 +0400, Клочков Роман wrote:
> How to make in Racket FFI struct with bit fields
> For example, such struct
>
> struct box_props
> {
> unsigned int opaque : 1;
> unsigned int fill_color : 3;
> unsigned int : 4; // fill to 8 bits
> unsigned int show_border : 1;
> unsigned int border_color : 3;
> unsigned int border_style : 2;
> unsigned int : 2; // fill to 16 bits
> };
>
> ?
The `ffi/unsafe' library currently doesn't include support for
bitfields. I think you have to declare a structure with an integer and
use operations like `arithmetic-shift' and `bitwise-and' to manipulate
bits in the integer.