Browse thread
[Caml-list] Returning a file handle from C (fopen)
-
Jeremy Cowgar
- David Brown
- Eric C. Cooper
[
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: | Eric C. Cooper <ecc@c...> |
| Subject: | Re: [Caml-list] Returning a file handle from C (fopen) |
On Tue, Sep 21, 2004 at 06:06:20PM -0400, Jeremy Cowgar wrote: > 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)); > [...] > 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. Have you called either flush or close_out on your handle? The OCaml channel values add a layer of buffering, similar to C stdio, on top of the file descriptor. -- Eric C. Cooper e c c @ c m u . e d u ------------------- 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