Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Calling C++ from Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-04-19 (12:00)
From: John Prevost <prevost@m...>
Subject: Re: Calling C++ from Caml
>>>>> "or" == Ohad Rodeh <> writes:

    or> Hello, I'm trying to use C++ code from within Caml. Currently,
    or> the compiler cannot find the requested functions in the
    or> compiled C++ code.


    or>   If I use the gcc compiler with C code, instead of C++, this
    or> sequence works fine. How can I fix this problem?

C++ compilers need to do "name-mangling" in order to support
overloading functions.  This adds information about the types of the
arguments to the function's name, and makes it hard for O'Caml to

I suspect that using the following prototype would work for you:

extern "C" {
  value dhml_Try(value dummy);

the `extern "C"' part requests that the following be done with C
calling conventions.  I'm not up on my C++, so this may be
insufficient when you're defining the function in the current
file--you may need to use the extern declaration around the function's