"Marcin 'Qrczak' Kowalczyk" <mk167280@zodiac.mimuw.edu.pl> wrote,
On Fri, 23 Feb 2001, Fergus Henderson wrote:
OK, now how about things where you need to #define symbols before including the header file?
Choose one: 1. Write a forwarding header which #defines and #includes.
That's exactly the way to do it.
3. Extend the proposed FFI to have define as well as include.
We can't extend the FFI to implement half the features of all the language we want to bind to. I agree with Alastair and SimonPJ that we have reached the maximum in add on features to Haskell for supporting foreign bindings. I am happy about any change that makes things more orthogonal or so, but I don't think we should add any more features without simplyfing something or taking something else out.
Unfortunately option 1 doesn't always work well on ghc, because Stg.h (included into .hc files) indirectly includes headers like <stdlib.h> *before* user-specified -#include options, so symbols like _BSD_SOURCE are defined too late to have any effects. This should be fixed.
Yes, but it's an implementation problem, not one of the FFI.
hsc2hs provides a mix of option 1 and option 2. You write #define in .hsc source before #include and it usually works, but sometimes it's too late. I hope this mess can be somewhat sorted out; symbols go into several files and it is messy.
Or where the header file to include varies depending on the system?
When you have conditional compilation (either via hsc2hs or via cpp), wrap the proposed 'foreign default include "..."' in appropriate #ifdefs.
Yep - tool support is of course fine, too. Cheers, Manuel