extended foreign decls

malcolm-ffi at cs.york.ac.uk malcolm-ffi at cs.york.ac.uk
Thu Jan 4 09:53:34 EST 2001


> Anyone who has tried to compile Linux code (intended for gcc) on
> some other compiler knows that people don't restrict themselves to
> the portable subset and, after a while, forget whether they're using
> extensions at all.

Or indeed, anyone who has tried to compile Haskell code intended
for GHC.  I am constantly surprised by what people think is "standard"
Haskell.  Standards are GOOD.  Extensions are BAD.

> ... use whatever flags or directives
> nhc/ffi provides to say "please #include this .h file".

Ah yes, the point is, neither nhc98 nor the common FFI has any
mechanism for saying "please #include this .h file".  I want one.
And I want a *standard* one.

foreign decl CPP {
  #define  _GNU_SOURCE
  #define  _XOPEN_SOURCE=500
  #include <stdio.h>
  #include "HsFFI.h"
}

> The current Hugs implementation of ffi could readily accomodate it
> because it generates a C file which you compile in the normal way
> but it would forever rule out an improved implementation (for use on
> especially well supported architectures) which doesn't need a compiler
> at all.

So you shift the burden of calling the C compiler out of the Haskell
system, and onto the user to do it manually?  Really, I'd rather the
Haskell system tried its best to do as much as possible automatically.

Regards,
    Malcolm




More information about the FFI mailing list