From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1F987BB9A for ; Tue, 8 Nov 2005 12:52:41 +0100 (CET) Received: from mx.laposte.net (mx.laposte.net [81.255.54.11]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA8BqeUa023623 for ; Tue, 8 Nov 2005 12:52:40 +0100 Received: from [192.168.0.37] (81.51.247.163) by mx.laposte.net (7.2.060.1) (authenticated as matthieu.dubuget) id 42DE178C04101081; Tue, 8 Nov 2005 12:52:04 +0100 Message-ID: <437091FD.3040102@laposte.net> Date: Tue, 08 Nov 2005 12:54:37 +0100 From: Matthieu Dubuget Reply-To: matthieu.dubuget@laposte.net User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: fr, en MIME-Version: 1.0 To: Dan Koppel Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] problem calling C-function from Ocaml References: <20051101020655.49021.qmail@web32209.mail.mud.yahoo.com> In-Reply-To: <20051101020655.49021.qmail@web32209.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 43709188.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; matthieu:01 dubuget:01 matthieu:01 dubuget:01 caml-list:01 ocaml:01 stub:01 stub:01 val:01 bytecode:01 argv:01 argv:01 mli:01 bytecode:01 camlprim:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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