diff options
Diffstat (limited to 'ffi')
| -rw-r--r-- | ffi/Bar.c | 3 | ||||
| -rw-r--r-- | ffi/Makefile | 4 | ||||
| -rw-r--r-- | ffi/barmain.hs | 6 |
3 files changed, 12 insertions, 1 deletions
diff --git a/ffi/Bar.c b/ffi/Bar.c new file mode 100644 index 0000000..3bf5008 --- /dev/null +++ b/ffi/Bar.c @@ -0,0 +1,3 @@ +double bar(double v){ + return v+v*v; +} diff --git a/ffi/Makefile b/ffi/Makefile index 6f098a6..849a8de 100644 --- a/ffi/Makefile +++ b/ffi/Makefile @@ -1,9 +1,11 @@ hask_from_c: Foo.hs foomain.c stack ghc -- Foo.hs stack ghc -- -no-hs-main Foo.o foomain.c -o hask_from_c - +c_from_hask: Bar.c barmain.hs + stack ghc -- barmain.hs Bar.c -o c_from_hask clean: - rm *.o - rm *.hi - rm Foo_stub.h - rm hask_from_c + - rm c_from_hask diff --git a/ffi/barmain.hs b/ffi/barmain.hs new file mode 100644 index 0000000..07e81ae --- /dev/null +++ b/ffi/barmain.hs @@ -0,0 +1,6 @@ +foreign import ccall "exp" c_exp :: Double -> Double +foreign import ccall "bar" c_bar :: Double -> Double + +main = do + print $ c_exp 2 + print $ c_bar 2 |
