From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA04080; Wed, 22 Sep 2004 03:21:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA03893 for ; Wed, 22 Sep 2004 03:20:59 +0200 (MET DST) Received: from ux9.sp.cs.cmu.edu (UX9.SP.CS.CMU.EDU [128.2.220.166]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id i8M1KsO0017419 for ; Wed, 22 Sep 2004 03:20:59 +0200 Received: from c-24-3-154-200.client.comcast.net ([24.3.154.200]) by ux9.sp.cs.cmu.edu id aa14742; 21 Sep 2004 21:20 EDT Received: from ecc by stratocaster.home with local (Exim 4.34) id 1C9voK-00017X-OC for caml-list@inria.fr; Tue, 21 Sep 2004 21:20:44 -0400 Date: Tue, 21 Sep 2004 21:20:44 -0400 To: OCaml Mailing List Subject: Re: [Caml-list] Returning a file handle from C (fopen) Message-ID: <20040922012044.GA4257@localhost> Mail-Followup-To: OCaml Mailing List References: <87k6un5lb7.fsf@jhome.cowgar.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k6un5lb7.fsf@jhome.cowgar.com> User-Agent: Mutt/1.5.6+20040722i From: "Eric C. Cooper" X-Miltered: at nez-perce with ID 4150D376.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 0400,:01 val:01 alloc:01 descriptor:01 printf:01 fprintf:01 buffering:01 stdio:01 descriptor:01 jeremy:01 ocaml:01 caml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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