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
[Caml-list] Using C values in ocaml code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-01-31 (10:11)
From: Tomasz Zielonka <zielony@c...>
Subject: [Caml-list] Using C values in ocaml code

I'm linking ocaml code with a program written in C. I want to use
some C type values within ocaml code (store in structures, pass around,
apply to external functions, etc.). Below is a simplified example:

  type cvalue

  external get_some_value : unit -> cvalue = "get_some_value"
  external process_value  : cvalue -> cvalue = "process_value"

example C primitive:

  get_some_value(value unit)
    Datum x;
    x = foo();
    CAMLreturn((value) x)

What I'm afraid of is: 
  Can there be any problem with Garbage Collector
... if cvalue is word aligned pointer? (I think I'll be ok)
... if cvalue can have any value?

My situation is that cvalue is word with any value possible - eg. it
can be a pointer or an integer.

Do I have to put it in a custom block or something?


   .-.   Tomasz Zielonka                           CYBER SERVICE
   oo|   programista              
 (\_;/)  tel: [48] (22) 723-06-79 | tel/fax: [48] (22) 723-01-75
Bug reports:  FAQ:
To unsubscribe, mail  Archives: