Version française
Home     About     Download     Resources     Contact us    
Browse thread
CAMLreturn does not work for floats between 0 and 1 ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] CAMLreturn does not work for floats between 0 and 1 ?

Le 16 févr. 07 à 17:20, Matthieu Dubuget a écrit :

> Suppose that I have to construct one or more value(s) to pass them to
> OCaml land. I do have to use CAMLlocal macros for that, don't I.

It depends. If you _allocate_ (e.g. ints are not allocated) a caml  
value v1 then another caml v2 and then modify v1, you need to keep a  
hand on v1 with CAMLparam because it may move when you allocate v2.  
If you allocate only a single value then there is no need to do it  
(unless some code you call may invoke the gc before you use v1).

> Can use them without CAMLparam and CAMLreturn macros?

No. But I never did the C -> ocaml -> C way so I don't really know  
how to proceed. The first thing that comes to mind is to store the  
result in a variable given to  the function.

void f1 (int i, double *result) {
	CAMLparam...
	*result = ...
	CAMLreturn0;
}

Maybe there's another way, I don't know.

Daniel