caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Laurent Thévenoux" <laurent.thevenoux@inria.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Interfacing C with OCaml and file descriptors
Date: Fri, 13 Oct 2017 12:57:33 +0200	[thread overview]
Message-ID: <3380AF33-0E0F-46E9-BF03-E61B65E6B838@inria.fr> (raw)

Hi,

I have a naive question about file descriptors and C interface (when interfacing C with OCaml).

For instance, a file.ml file which looks like:


external my_c_interface : out_channel -> int = c_function


where c_function writes something to a file and return the number of written char.
The c_function takes a FILE* file descriptor, as for example:


CAMLprim value c_function (value channel)
{
	CAMLparam1 (channel);
	FILE* fd = ???;
	CAMLreturn (Val_int (call_to_c_func (fd)));
}


So, if possible, how to convert the ‘value channel’ to a ‘FILE*’?

Thanks for your help,
Laurent

             reply	other threads:[~2017-10-13 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 10:57 Laurent Thévenoux [this message]
2017-10-13 11:10 ` Nicolás Ojeda Bär
2017-10-13 21:37 ` Richard W.M. Jones
2017-10-13 22:42   ` David Allsopp
2017-10-14  6:10     ` Richard W.M. Jones
2017-10-14 15:18   ` Malcolm Matalka
2017-10-14 15:54 ` Thierry Martinez
2017-10-16  6:46   ` Laurent Thévenoux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3380AF33-0E0F-46E9-BF03-E61B65E6B838@inria.fr \
    --to=laurent.thevenoux@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).