From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA18789; Fri, 5 Jul 2002 11:46:15 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA18677 for ; Fri, 5 Jul 2002 11:46:14 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g659kDf14588; Fri, 5 Jul 2002 11:46:13 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA18449; Fri, 5 Jul 2002 11:46:12 +0200 (MET DST) Date: Fri, 5 Jul 2002 11:46:12 +0200 From: Xavier Leroy To: Thierry SALSET Cc: caml-list@inria.fr Subject: Re: [Caml-list] interfacing C++ with OCaml Message-ID: <20020705114612.C16273@pauillac.inria.fr> References: <20020704.192114.115911667.ts@cassis.enpc.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20020704.192114.115911667.ts@cassis.enpc.fr>; from ts@cermics.enpc.fr on Thu, Jul 04, 2002 at 07:21:14PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I used Camlidl to help me interface C functions and datatypes with OCaml > under Unix but now I would like to interface some existing (written by > others) C++ classes and methods with OCaml. I am not a C++ programmer > and I'm a little bit lost. Can Camlidl be of some help ? Should I write > a C layer between C++ and OCaml ? This is a reasonable option. Once you have a pure C API for the C++ code, you can use CamlIDL as usual. CamlIDL itself doesn't have any kind of direct support for C++. Well, it supports COM interfaces, which correspond to a very small subset of C++ classes, but I doubt this can help you, unless the C++ code of interest is already structured as COM interfaces. The other alternative is to hand-write Caml wrappers that call directly the C++ code, without going through C. I believe you can write those wrappers in C++ if you're careful to declare the entry points (the functions that Caml will call) "extern "C"". Some of the features of C++ might be used to wrap the Caml runtime API (the functions and macros provided by , etc) in a more C++-friendly style, see e.g. http://caml.inria.fr/archives/199704/msg00029.html Bon courage... - Xavier Leroy ------------------- 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