Generating Function Prototypes
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Wed Jul 3 05:57:31 EDT 2002
Ashley Yakeley <ashley at semantic.org> writes:
> 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.
The "proper" way to do it is to write the prototype yourself in a
C header file (or use an existing header), and then use a compiler-specific
mechanism to #include it.
> Why doesn't Haskell generate a prototype from the 'foreign import'
> declaration, as part of the -fvia-C compilation?
The nhc98 compiler does generate a prototype (ghc does not). However,
although this works quite well in the general case, occasionally the
generated prototype may not be compatible with the real C type of
the function (e.g. it cannot guess the `const' attribute).
Regards,
Malcolm
More information about the FFI
mailing list