FFI: calling Haskell from C++?

Rich Neswold rich.neswold at gmail.com
Wed Sep 14 12:00:20 EDT 2005


On 9/14/05, Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> 
>  There's been a bit of traffic about calling Haskell from C++ recently, 
> and I know that calling C++ from Haskell is a frequently asked question.
> 
> Would someone like to write up a description of how
> to successfully call out from Haskell to C++ and vice versa,
> using GHC? 
> If you did, we'd gladly include the result in the user manual, and save 
> others a lot of head scratching. Maybe there are simple things we could do 
> to GHC to make the process simpler. But what it needs is someone who knows 
> C++ well to write a coherent story. Please!
> 

I'm flattered that you quoted my message, but I'm not familiar with the 
foreign language interface; I started looking at Haskell only a few weeks 
ago.

I was able to fix the first problem, since the name-mangler is always a 
problem when mixing other languages with C++. The second error I may or may 
not have got right. The other solution recommended that the C++ library be 
linked which fixes the undefined exception handling symbols. I'm curious 
what would happen if Haskell called down into C++ code and then an exception 
was thrown...

Anyways, I think your suggestion is a good one and I would be willing to 
answer any C++ questions that anyone has when writing such a document.

-- 
Rich

AIM : rnezzy
ICQ : 174908475
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/glasgow-haskell-users/attachments/20050914/d5610a19/attachment.htm


More information about the Glasgow-haskell-users mailing list