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.
I agree. Would it be fixed by just #including Stg.h after any -#includes, or would that create more problems? Cheers, Simon
On Fri, 23 Feb 2001, Simon Marlow wrote:
I agree. Would it be fixed by just #including Stg.h after any -#includes, or would that create more problems?
If HsFFI.h indirectly includes system headers, then I'm afraid it's not enough for hsc2hs, which automatically includes HsFFI.h before user-specified #includes (because it cannot reliably determine where #includes end and code which relies on HsFFI.h begins). Can HsFFI.h be made self-contained? Requiring to include HsFFI.h explicitly (after system includes) would work, but I hope it can be avoided. Generally I can't fit the whole picture of files included at all places in my head at once. -- Marcin 'Qrczak' Kowalczyk
On 23-Feb-2001, Simon Marlow <simonmar@microsoft.com> wrote:
I agree. Would it be fixed by just #including Stg.h after any -#includes, or would that create more problems?
ghc uses gcc global register variables on x86, doesn't it? If so, they need to be declared first thing, before any function definitions; and system headers often define inline functions. So if Stg.h declares global register variables, they need to come first. You may need to split Stg.h into the part which declares the global register variables, and the remainder, and put just the first part before the user's #includes. Another (probably better) alternative is to pass the `-ffixed-<reg>' option to gcc to reserve the registers. -- Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
participants (3)
-
Fergus Henderson -
Marcin 'Qrczak' Kowalczyk -
Simon Marlow