Interfacing C procedure using an array as parameter ?

From: Vincent B.G. Leleu (vincent@parc.anglia.ac.uk)
Date: Mon Apr 28 1997 - 16:46:15 MET DST


Date: Mon, 28 Apr 1997 15:46:15 +0100
From: "Vincent B.G. Leleu" <vincent@parc.anglia.ac.uk>
To: caml-list@inria.fr
Subject: Interfacing C procedure using an array as parameter ?

[French version at the bottom]

        Hello all,

        Firstly, thanks to those of you who provided me with
        information about C++/OCaml interfacing, this has been
        very usefull.

        This is the first time I interface C/OCaml and also I have
        a problem : How do I use a parameter which is a pointer
        on the beginning of an integer array ?

        The C prototype :
        ----------------

        void EndConfig(int *tid, int nb_tids);
        /* tid is a pointer on an array of task id
           nb_tids is the number of task id in the array */

        the Caml interface :
        -------------------

        external end_config : int vect -> unit;;

        value end_config(tids)
          value tids;
        {
           /* what do I put here ? */
        }

        Though the RM provides an example with return list (p.122-3)
        I am a bit lost regarding the use of vectors.

                Thanks for any help,

                Vincent.

[Version francaise]

        Bonjour at tous,

        Tout d'abord merci aux personnes qui m'ont fourni des
        informations a propos de l'interfacing de C++/OCaml,
        elles ont ete tres utiles.

        C'est la premiere fois que j'interface C/OCaml et aussi
        j'ai un probleme : Comment utiliser un argument qui est
        un pointeur sur le debut d'un tableau d'entiers ?

        Le prototypage C :
        -----------------

        void EndConfig(int *tid, int nb_tids);
        /* tid is a pointer on an array of task id
           nb_tids is the number of task id in the array */

        l'interface Caml :
        -----------------

        external end_config : int vect -> unit;;

        value end_config(tids)
          value tids;
        {
           /* que dois-je mettre ici ? */
        }

        Bien que j'ai trouve un exemple dans le MR avec un retour
        de liste (p.122-3) je suis un peu perdu en ce qui concerne
        l'utilisation des vectors.

                Merci pour votre aide,

                Vincent.

______________________________________________________________

  Vincent B.G.Leleu
  Parallel Computing Research Centre
  Anglia Polytechnic University
  Victoria Rd. South, Chelmsford
  Essex CM1 1JJ
  England

  E-Mail : mailto:vincent@parc.anglia.ac.uk
  URL : http://www.parc.anglia.ac.uk/~vincent
  Phone : +44 1245 493131 ext. 3416
  Fax : +44 1245 495263 - PARC
  Pager : +44 1426 634330 (phone numbers only)



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:10 MET