Wolfgang Thaller wrote:
[...] *) static constructors/destructors
Sometimes there are pieces of code that expect to be called before
main() or at program termination. The GHCi Linker doesn't support this,
so some code may crash because things haven't been initialised properly.
This will definitely be a source of trouble if you use any C++ library
whatsoever.
I don't know the story for Linux, but at least one other platform I know has the
addresses of those constructors/destructors in special ELF sections. GHCi could
easily iterate through these, but this is really highly platform-specific. There
used to be a description of a widespread C++ ABI on codesourcery.com, but I
can't
find it anymore... :-(
*) multiple definitions
There is often some code in C++ header files (e.g. templates, inline
functions, class members declared in the class declaration). These
pieces of code are sometimes inlined, but sometimes they are not; in
that case, gcc generates code for them in every .o file that uses them
and counts on the linker to just include one version in the final
executable. The GHCi linker will probably just abort and complain about
multiply-defined symbols.
IIRC, g++ uses weak symbols for this, at least on some platforms. Handling
these
doesn't sound too hard (easy sentence when one doesn't intend to implement it
:-).
The above is just theory, there might be even more problems in practice
:-( .
Exception handling comes to my mind. Nowadays it's often done via stack
unwinding,
but I don't know about the details anymore. This might cause some trouble when
C++ code is called from Haskell.
The only golden rule I know about this all: Use only a single C++ compiler for
the
compilation *and* linking of all your libraries and programs, otherwise be
prepared
for long hours in front of gdb... :-(
Cheers,
S.
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users