Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: John Prevost <prevost@m...>
Subject: Re: Calling C++ from Caml
>>>>> "or" == Ohad Rodeh <orodeh@cs.huji.ac.il> 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
find.

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

John.