[ocaml-ctypes] Passing a pointer to a struct by address

Thomas Braibant thomas.braibant at gmail.com
Thu Sep 11 09:53:54 BST 2014


Answering my own question, it appears that
let p = allocate_n ~count:1 ((ptr my_struct)) in
let rv = f p in
    ....

does what I want. Sorry for the noise.

On Thu, Sep 11, 2014 at 10:31 AM, Thomas Braibant
<thomas.braibant at gmail.com> wrote:
> Hi list,
>
> I am struggling with one part of a binding I am working on, which
> requires me to give a pointer to a pointer to a struct as an argument
> to a function. The idea is that this corresponds to giving a pointer
> to a struct by address to the function, which is free to use its
> return type to return error codes.
>
> What would be the correct idiom to do that? I could not find a way to
> get the address of a pointer in Ctypes itself, and I wonder if that
> would even be possible?
>
> Best,
> Thomas
>
> (My subscription to this list is still in limbo, so do not forget to CC me ;))


More information about the Ctypes mailing list