[racket] FFI bitfields
Is it planned to add this support? I roughly imagine, how to make bit fields inside int , but C standard allows bit fields to be, for example, 35 bit total.
Вторник, 11 июня 2013, 6:03 -07:00 от Matthew Flatt <mflatt at cs.utah.edu>:
>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.
>
--
Роман Клочков