caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matthieu Dubuget <matthieu.dubuget@laposte.net>
To: Dan Koppel <superluminal1905@yahoo.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] problem calling C-function from Ocaml
Date: Tue, 08 Nov 2005 12:54:37 +0100	[thread overview]
Message-ID: <437091FD.3040102@laposte.net> (raw)
In-Reply-To: <20051101020655.49021.qmail@web32209.mail.mud.yahoo.com>

Dan Koppel a écrit :

> Here is the C "stub function" that I use:
>  
> value stub_myCTime(
>         value _v_dummy)
> {
>   int dummy; /*in*/
>   float _res;
>   value _vres;
>   dummy = Int_val(_v_dummy);
>   _res = myCTime(dummy);
>   _vres = copy_double(_res);
>   return _vres;
> }
> value stub_myCTime_bytecode(value * argv, int argn)
> {
>   return stub_myCTime(argv[0]);
> }
>  
> and here is the .ml/.mli file that I use:
>  
> external myCamlTime : int -> float
>         = "stub_myCTime_bytecode" "stub_myCTime"
>  

I did not try. Here is the stub function I would have written (no need
for a distinct bytecode/native stub function, since there are less than
5 parameters.

CAMLprim value stub_myCTime(value _v_dummy){
CAMLparam1(_v_dummy);
int dummy;
dummy = Int_val(_v_dummy);
CAMLreturn( copy_double(myCTime(dummy)) );
}

The only point I think of  that you should check is: are the CAMLparam1
and CAMLreturn macros mandatory in your case?
I think that you are using a code that was generated by camlidl, am I
right? If this is the case, did you modify it?

Salutations

Matthieu


      reply	other threads:[~2005-11-08 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-01  2:06 Dan Koppel
2005-11-08 11:54 ` Matthieu Dubuget [this message]

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=437091FD.3040102@laposte.net \
    --to=matthieu.dubuget@laposte.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=superluminal1905@yahoo.com \
    /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).