[ocaml-ctypes] Unsigned int smaller than 32 bits
Daniel Bünzli
daniel.buenzli at erratique.ch
Sun Dec 22 01:47:48 GMT 2013
Hello,
Is there any particular reason why signed int smaller than 32 bits are accessed as ocaml ints but unsigned ints smaller than 32 bits are not ?
In both cases you need to care about the range if you represent them as ocaml ints, and in both cases you want to represent them by ocaml ints if you don't want ctypes types to leak in the interface. I must be missing something.
Best,
Daniel
P.S. Already tired of writing:
let int_as_uint8_t =
view ~read:Unsigned.UInt8.to_int ~write:Unsigned.UInt8.of_int uint8_t
let int_as_uint16_t =
view ~read:Unsigned.UInt16.to_int ~write:Unsigned.UInt16.of_int uint16_t
More information about the Ctypes
mailing list