caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Prevost <prevost@maya.com>
To: Ohad Rodeh <orodeh@cs.huji.ac.il>
Cc: caml-list@inria.fr
Subject: Re: Calling C++ from Caml
Date: 17 Apr 2000 15:25:36 -0400	[thread overview]
Message-ID: <871z44lebz.fsf@isil.localdomain> (raw)
In-Reply-To: Ohad Rodeh's message of "Sun, 16 Apr 2000 16:40:44 +0300 (IDT)"

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



      reply	other threads:[~2000-04-19 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-16 13:40 Ohad Rodeh
2000-04-17 19:25 ` John Prevost [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871z44lebz.fsf@isil.localdomain \
    --to=prevost@maya.com \
    --cc=caml-list@inria.fr \
    --cc=orodeh@cs.huji.ac.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).