From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA28355; Wed, 15 Jan 2003 16:09:23 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA30073 for ; Wed, 15 Jan 2003 16:09:22 +0100 (MET) Received: from inria.fr (macaque.inria.fr [128.93.8.158]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0FF8pr07100; Wed, 15 Jan 2003 16:08:51 +0100 (MET) Date: Wed, 15 Jan 2003 16:10:30 +0100 Subject: Re: [Caml-list] C -> CAML linking: loosing values in arrays?? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Caml List To: Daniel.Andor@physics.org From: Damien Doligez In-Reply-To: <200301111907.51989.da209@cam.ac.uk> Message-Id: <7C799FA7-289B-11D7-AFEF-0003930FCE12@inria.fr> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Saturday, January 11, 2003, at 08:07 PM, Daniel Andor wrote: > parameters. Since it's for numerics, I want to pass arrays of doubles. > return alloc_array(make_float,p); You cannot use alloc_array to return a value of type [float array]. This is because arrays of floating-point numbers are not represented like the other array types in O'Caml: they are allocated in-line, without the usual pointer indirection. You will have to allocate the array with [alloc], then fill in the elements with [Store_double_field]: #define NUM_DIMS 4 value make_float_array(double *ds) { int i; value res; res = alloc (NUM_DIMS*Double_wosize, Double_array_tag); for (i=0; i