[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Guillaume Yziquel <guillaume.yziquel@c...> |
| Subject: | Re: [Caml-list] problem creating .cma library |
Damien Doligez a écrit :
>
> On 2009-12-31, at 00:30, Guillaume Yziquel wrote:
>
>>> #include <stdio.h>
>>> #include <caml/mlvalues.h>
>>> #include "../mylib/mylib.h"
>>> CAMLprim value
>>> my_print_stub(value v) {
>>
>> CAMLparam1(v); /* is missing here, for garbage
>> collection purposes. */
>>
>>> char* str = (char*)String_val( v );
>>
>> /* You do not need the right-hand side (char*) casting. */
>>
>>> my_print( str );
>>> return Val_unit;
>>> }
>
> If you use CAMLparam1, you must use CAMLreturn instead of return.
Yes. Indeed. Didn't see it.
However, I had a look at
https://yquem.inria.fr/caml/svn/ocaml/version/3.09/byterun/sys.c
and more specifically at the function
> CAMLprim value caml_sys_exit(value retcode)
> {
> #ifndef NATIVE_CODE
> caml_debugger(PROGRAM_EXIT);
> #endif
> exit(Int_val(retcode));
> return Val_unit;
> }
or the function
> CAMLprim value caml_sys_close(value fd)
> {
> close(Int_val(fd));
> return Val_unit;
> }
Why do these functions not follow the usual CAMLparam/CAMLreturn macro
stuff?
--
Guillaume Yziquel
http://yziquel.homelinux.org/