scope of header files

Simon Marlow simonmarhaskell at
Wed Mar 12 18:10:27 EDT 2008

John Meacham wrote:
> On Tue, Mar 11, 2008 at 02:47:37PM -0700, Simon Marlow wrote:
>> Yeah, I'd like -fvia-C to be headerless.  We talked about it a while back 
>> (on the haskell-prime list I think).  The main issue is that GHC would have 
>> to generate prototypes based on the FFI declaration, and since it can't 
>> guarantee to generate a prototype that is exactly the same as the C 
>> prototype given in the header file (e.g. it doesn't know about const), we 
>> would have to ensure that there really are no other prototypes in scope, to 
>> prevent errors from the C compiler.
> I was thinking that you just wouldn't include any extra c headers at all
> then, just write out the appropriate c code to call with the conventions
> specified in the ffi import specification and you won't need external
> headers at all so there isn't anything to conflict with.

Yes, pretty much.  There are a bunch of C headers that define the macros 
used by the generated C code, and we have to be careful that they don't 
include anything external - in the past we used to #include several 
things from /usr/include, but I think we're much cleaner these days.


More information about the Glasgow-haskell-users mailing list