English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] OCaml popularity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-13 (08:59)
From: francois bereux <francois.bereux@f...>
Subject: [Caml-list] how to interface with integer Bigarrays using camlidl

I posted this question on the beginner list, but I got no answer.
I do not manage to interface a 1D Bigarray of integers with C code, using
Here is an example :

----- code.c ------
void linear( int* m, int* ia )
   int i;
   for( i=0; i< *m; i++ ) { ia[i] = i; }

----- bug.idl -----
void linear( [in,ref] int* m, [in,out,length_is(*m),bigarray] int ia[] );

----- test.ml -----
open Bigarray;;
open Bug;;

let lin n =
   let ia = Array1.create int32 c_layout n in
      begin linear ia; ia; end;;

------ Makefile ------
SOURCES = code.c bug.idl test.ml
LIBS = bigarray
RESULT = essai


When I compile, I get the following error :
File "test.ml" line 7, character 12-14
This expression has type
   (int32, Bigarray.int32_elt, Bigarray.c_layout) Bigarray.Array1.t
but is here used with type
   (int, Bigarray.int32_elt, Bigarray.c_layout) Bigarray.Array1.t

As far as I understand, the kind of the array in the stub code generated by
camlidl is (int,int32_elt) kind, whereas the
int32 in my test.ml file defines a (int32, int32_elt) kind. Am I correct ? And how
can I modify my code so that it works ?
( I do not know how to define by myself an Array1 with (int, int32_elt) kind. )

If I use floats in the code, this works fine.

Any help would be appreciated,

Sincerely yours,

F. Béreux

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners