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] 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: 2004-09-22 (01:21)
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 Archives:
Bug reports: FAQ:
Beginner's list: