Version française
Home     About     Download     Resources     Contact us    
Browse thread
Unsigned int ?!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: thierry BRAVIER <thierry.bravier@d...>
Subject: Re: Unsigned int ?!
Luc MAZARDO a écrit:

> I would like to get the "caml unsigned int value" of an "unsigned int C
> value". Is there a way to do this ??
>
> I do the following, and it fails ...
>
> ---toto_stub.c---
> value toto(void)
> {
>   return Val_int(get());
> }
> ------------

I think you should add:
value toto_external (value unit) { /* unit is  necessary for this external
function */
   return toto ();
}

> ---toto.mli---
> val toto : unit -> int ;;
> ------------
>
> ---toto.ml---
> external toto : unit -> int = "toto";;

Here you would rather write:
external toto : unit -> int = "toto_external";;

Anyway whether your version fails, returns a wrong result or anything else
cannot be predicted
since it is related to the function call protocol of your machine.

Or maybe I am wrong since I did not try this on my computer  :-)

Hope this helps.

Thierry Bravier