A question

Alastair Reid alastair@reid-consulting-uk.ltd.uk
23 Jul 2002 17:03:09 +0100


> [...] all opengl true type font renderers are written in C++, no
> one is written in C.

> If I want to write haskell bindings for such a thing, what can I do?

Interfacing to C++ is hard because of the mismatch between the Haskell
and C++ typesystems.  There are two solutions:

1) Make your C++ interface look like COM and use H/Direct.

2) Make your C++ interface look like C (which is more or less Haskell
   without the type classes) and use an ffi frontend (or raw ffi).

   We used to do this at Yale.  If doing this with Hugs, you have to
   be sure to link Hugs with a C++ compiler and may need to use
   'export "C" { ... }' in header files and compile generated code
   with a C++ compiler.  (The same may well be required if using
   H/Direct.)

The first is best if you want to preserve some of the type structure
present in the original code or if you want to want to/can reuse IDL
bindings

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/