Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Returning a file handle from C (fopen)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jeremy Cowgar <jc@c...>
Subject: [Caml-list] Returning a file handle from C (fopen)
Greetings,

I am trying to return a file handle from C. A simple Val_long does not
work, so I did some research and found something like the following:

  return caml_alloc_channel(caml_open_descriptor_out(myhandle));

This compiles (with 2 warnings):

  warning: implicit declaration of function `caml_alloc_channel'
  warning: implicit declaration of function `caml_open_descriptor_out'

However, the functions should be avaliable once running in ocaml, no?

Anyway, my real problem lies in the fact that when I do something like:

let fh = get_my_out_handle () in
Printf.fprintf fh "Hello, World!\n";;

nothing appears in my output file. No warning, errors or anything. In my
C source, I can do the exact thing and the contents are written.

Can anyone help me return a file handle from C to OCaml that can be used
with the OCaml output/input functions? I do realize a different type
would have to be returned for input/output. I was working on the output
portion first.

Thanks,

Jeremy Cowgar

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners