caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anne Pacalet <anne.pacalet@tele2.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Toplevel crashes when trying to call external functions
Date: Mon, 12 Jul 2004 08:55:31 +0200	[thread overview]
Message-ID: <40F235E3.5070600@tele2.fr> (raw)
In-Reply-To: <20040711012047.86808.qmail@web53203.mail.yahoo.com>

Andy Yang a écrit :
> I am relatively new to Ocaml. 

I am VERY new to Ocaml...

> When I call these functions in a .ml file. It is okay.
> .However, when I tried to call these functions
> interactively, segmentation fault happens.

and I have to same problem with even the simplest functions.
For instance :

extern "C" void Caml_load_project(value v_0){
   CAMLparam1(v_0);
   String x_0 = String_val (v_0);
   C_load_project (x_0);
   CAMLreturn0;
}
extern "C" value Caml_show_refs(value v_0, value v_1){
   CAMLparam2(v_0, v_1);
   CAMLlocal1 (v_res);
   int x_0 = Int_val (v_0);
   int x_1 = Int_val (v_1);
   std::list<int> res = C_show_refs (x_0, x_1);
   v_res = Val_listInt (res);
   CAMLreturn (v_res);
}

And I noticed that if I add "flush" or "print" calls, it works.
So, I did :

external c_load_project : string -> unit = "Caml_load_project"
external c_show_refs : int -> int -> int list = "Caml_show_refs"

let load_project a_0 =
   c_load_project a_0 ; flush_all()
;;
let show_refs a_0 a_1 =
   let r = c_show_refs a_0 a_1 in flush_all() ; r
;;

and the functions 'load_project' and 'show_refs' work fine even 
interactively. I don't know why (I would be happy to know)... but maybe 
this workaround can help !

Bye,
Anne.

-------------------
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


  parent reply	other threads:[~2004-07-12  6:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-11  1:20 Andy Yang
2004-07-11 18:14 ` art yerkes
2004-07-11 18:58   ` Andy Yang
2004-07-12 11:04     ` Gerd Stolpmann
2004-07-12 11:35     ` Damien Doligez
2004-07-12 13:16       ` Andy Yang
2004-07-12 13:33         ` Olivier Andrieu
2004-07-12 15:39           ` Andy Yang
2004-07-12  6:55 ` Anne Pacalet [this message]
2004-07-12  3:39 John Prevost
2004-07-12  4:46 ` Andy Yang
2004-07-12 10:55 ` Gerd Stolpmann
2004-07-12 12:03   ` Richard Jones
2004-07-12 12:55     ` Jean-Christophe Filliatre

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=40F235E3.5070600@tele2.fr \
    --to=anne.pacalet@tele2.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).