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: -- (:)
From: Jeremy Cowgar <jc@c...>
Subject: [Caml-list] Returning a file handle from C (fopen)

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.


Jeremy Cowgar

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: