Binding to inline functions
marlowsd at gmail.com
Wed Aug 26 04:18:55 EDT 2009
On 25/08/2009 13:45, Maurício CA wrote:
>>>> I understand we can't use 'foreign import ccall'
>>>> to wrap inline C functions. Do you think it could
>>>> be possible to have an option in cabal to generate
>>>> such functions in an object file when #included in
>>>> a C file, in a compiler independent, portable way?
>> I think it would be easy to do in GHC. We already have the machinery
>> to generate the _stub.c files and compile them.
>> The main question is what the syntax should look like. I was toying with
>> foreign import capi "foo" foo :: ...
> Under that syntax, how would GHC know where to find
> declaration/definition for a function? Since it's not,
> by hypothesis, on an object or library file, a C file
> will have to be compiled to get both the declaration
> and the definition.
Yes, absolutely. GHC will inject a C wrapper function into the _stub.c
file, compile it, and then call the wrapper from Haskell.
More information about the Libraries