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
camlidl and 2D arrays with the [out] attribute
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-15 (20:15)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] camlidl and 2D arrays with the [out] attribute
Hezekiah M. Carty wrote:

>I am attempting to use camlidl to wrap a function with the following C
>prototype portion (see [1] for the full prototype):
>... void c_plriddata( ... int nptsx, ... int nptsy, [out,
>size_is(nptsx,nptsy)] double ** zg ...);
>There is a lot more in the full prototype [1], but these are the
>important bits for this question.  In this form, the 2D zg array is
>not allocated as I would have expected.  Rather than allocating a
>rectangular nptsx by nptsy array, the generated C is:
>zg = camlidl_malloc(nptsx * sizeof(double *), _ctx);
I think the problem is with your C code.  zg is defined as a pointer to 
a pointer- not a pointer to an array!  And yes, Virginia, there is a 
difference.  If c_plriddata is accessing this pointer as a pointer to an 
array, you probably have a bug in your C code.