Generating Function Prototypes

Simon Marlow simonmar at microsoft.com
Wed Jul 3 05:54:53 EDT 2002


> I've been having trouble with an imported function that returns 
> Int64/"long long". Haskell doesn't generate a prototype, so 
> regular 'int' 
> type is assumed.
> 
> Why doesn't Haskell generate a prototype from the 'foreign import' 
> declaration, as part of the -fvia-C compilation? When the 
> prototype is 
> omitted, a default one is assumed. Surely FFI can improve on 
> the default 
> with the information given by the 'foreign import' declaration?
> 
> In the mean time, how do I work around the problem and provide a 
> prototype myself?

In GHC, you bring a prototype into scope either by using the string in
the foreign import declaration to specify a header file, or you specify
a header file in a command-line flag (-#include "foo.h" for example).
The command-line flag can be also given in the source file using an
OPTIONS pragma.

Generating a prototype is not possible, I'm afraid (see previous
discussion for the gory details).

Cheers,
	Simon



More information about the FFI mailing list