Dear Philippe,
On 16/05/2014, Philippe Veber <[email protected]> wrote:
> Has ctypes some support for bit fields in C struct?
Not yet, I'm afraid.
> If not is it correct to
> encode:
>
> typedef struct {
> int32_t pos;
> uint32_t bin:16, qual:8, l_qname:8;
> ...
> } bam1_core_t
>
> as:
>
> type bam1_core_t
> let bam1_core_t : bam1_core_t structure typ = structure "bam1_core_t"
> let bam1_core_t_pos_f = field bam1_core_t "pos" int32_t
> let bam1_core_t_props_f = field bam1_core_t "props" int32_t
> ...
> let () = seal bam1_core_t
>
> and then play with the fake "props" field directly?
It's quite likely to work but it's not guaranteed, since the C
standard gives compilers a fair amount of freedom in laying out
bit-fields. The good news is that the standard also requires
compilers to document how bit-fields are laid out, so your compiler
documentation may have helpful details.
Kind regards,
Jeremy.
_______________________________________________
Ctypes mailing list
[email protected]
http://lists.ocaml.org/listinfo/ctypes