[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <xavier.leroy@i...> |
| Subject: | Re: [Caml-list] interfacing C++ with OCaml |
> 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 <caml/mlvalues.h>, 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