caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Frank Christoph <christo@nextsolution.co.jp>
To: caml-list@pauillac.inria.fr
Subject: Need help: O'Caml C Interface
Date: Tue, 24 Sep 1996 00:09:43 +0900	[thread overview]
Message-ID: <9609231509.AA03139@sparc3.nextsolution.co.jp> (raw)


I have a C function 

  void getCharWidth(int code, double *x, double *y);

which returns its values in the two pointer arguments.  I tried to write a
stub function that creates a 2-tuple and passes it back:

  external width : int -> float * float = "ocaml_getCharWidth"

via:

value ocaml_getCharWidth(value code)
{
  double x, y;
  Push_roots(r,1);

  r[0] = alloc_tuple(2);
  getCharWidth(Int_val(code),&x,&y);
  Store_double_val(Field(r[0],0),x);
  Store_double_val(Field(r[0],1),y);
  Pop_roots();
  return r[0];
}

where I used Store_double_val because, as far as I can see, there is no
"Val_double" macro.  However, this gives me a segmentation fault.  I'm not
really sure I understand how the *_roots functions work.  Do the two local
variables x and y need to be declared as of type value?  If so, how can I
pass them to getCharWidth (since Double_val doesn't return an lvalue)?  What
am I doing wrong?

------------------------------------------------------------------------
Frank Christoph                 Next Solution Co.      Tel: 0424-98-1811
christo@nextsolution.co.jp                             Fax: 0424-98-1500





             reply	other threads:[~1996-09-24 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-23 15:09 Frank Christoph [this message]
1996-09-24 13:36 ` Jerome Vouillon
1996-09-24 14:45 Juan Jose Quintela Carreira
1996-09-24 17:11 ` Jerome Vouillon

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=9609231509.AA03139@sparc3.nextsolution.co.jp \
    --to=christo@nextsolution.co.jp \
    --cc=caml-list@pauillac.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).