Summary of current change suggestions

Marcin 'Qrczak' Kowalczyk mk167280 at
Fri Feb 23 08:59:20 EST 2001

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.
2. Use compiler-specific switches to get #defines (-D and -optc-D in ghc).
3. Extend the proposed FFI to have define as well as include.

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.

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.

Marcin 'Qrczak' Kowalczyk

More information about the FFI mailing list