4 Nov 21:01
Interfacing with C: array of integers as an ocaml string?
From: Hugo Ferreira <hmf <at> inescporto.pt>
Subject: Interfacing with C: array of integers as an ocaml string?
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-04 20:03:52 GMT
Subject: Interfacing with C: array of integers as an ocaml string?
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-04 20:03:52 GMT
Hello,
I recall that the question has been discussed before,
but I cannot find the post. Maybe someone can point me
in the right direction?
I am attempting to interface with a C library. The
function I require fills in an array with integers.
I have coded the call so:
CAMLprim value camlidl_cudd_bdd_pick_one_cube(
value _v_no)
{
CAMLparam1(_v_no) ;
bdd__t no; /*in*/
char *cube;
int result;
int size;
camlidl_cudd_node_ml2c(_v_no, &no);
size = Cudd_ReadSize(no.man);
printf("No of vars = %d\n", size);
cube = malloc((size+1) * sizeof(char));
cube[size] = 0 ;
result = Cudd_bddPickOneCube(no.man,no.node,cube); <- call in question
if (result!=1)
{ failwith("Bdd: pick cube failed!"); };
for(int i = 0 ; i < size ; i++) {
(Continue reading)
RSS Feed