Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Give back a Pair from C to OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-17 (15:37)
From: Berke Durak <berke.durak@e...>
Subject: Re: [Caml-list] Give back a Pair from C to OCaml?
Oliver Bandel a écrit :
> Hello,
> how can I give back a pair of values (in my case both are
> int's) from C to OCaml?
> Didn't found something in the docs so far.

Just allocate a block of size two and store your integers in the two 
fields of the block.

pairv = caml_alloc(2, 0);
Store_field(pairv, 0, Val_int(x));
Store_field(pairv, 1, Val_int(y));