Hi there,

> Hello, I have tried to export haskell functions, but I 
> haven't been able to compile anything and obtain a executable 
> file. My program has two parts. 
>  - Haskell part:
>       module Hex where
>       fh :: Int -> Int
>       foreign export "f"  fh :: Int -> Int
>       fh x = 7    
> 
>  - C part:
>       #include <stdio.h>
>       #include <stdlib.h> 
>       extern int f(int x);
> 
>       int main( ){
>       int a;
>       a = f(5);
>       printf("%d\n",a);
>       return 0;
>       }

When you provide your own main() function, you have to arrange to
initialize GHC's runtime system.  I've attached some example code, and
I've added some material to the User's Guide for the next release which
explain how to do this.

Cheers,
        Simon

ffi002_c.c

ffi002.hs

Reply via email to