[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] FFI, C/C++ and undefined references

Subject: Re: [Haskell-cafe] FFI, C/C++ and undefined references
From: "Brandon S. Allbery KF8NH"
Date: Wed, 13 Jan 2010 23:40:45 -0500
On Jan 13, 2010, at 23:28 , DNM wrote:
Sorry. In my haste to paste in the .c file, I left out all the include
statements.  I do have #include "srilm.h" there (which to my non-
C/C++ mind seems stupid -- why the hell would you need to import
the header file for the code that it's a header *for*?)

Really, the only reason in this case is that there is no equivalent for `extern "C"' that you can apply to a function definition, only to a declaration. The rationale is that everything that works with the function, including its definition, needs to see that declaration, so rather than repeat it in the definition you #include the declaration.
In GHC, this is the kind of thing that lands in the .hi file; the
tradeoff is you need to have up to date .hi files for everything that
needs to see that information, which can lead to dependency loops.
GHC has a ".hs-boot" hack to work around this. No free lunch....
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university    KF8NH

Haskell-Cafe mailing list
[email protected]
<Prev in Thread] Current Thread [Next in Thread>