Created
April 12, 2012 11:06
-
-
Save lewurm/2366554 to your computer and use it in GitHub Desktop.
ghci doesn't work with FFI export declarations?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.hi | |
*_stub.* | |
ffiso |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/10123040/ghci-doesnt-work-with-ffi-export-declarations-shared-libaries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void callMeFromC(void); | |
void callMeFromHaskell(void) | |
{ | |
printf("callMeFromHaskell\n"); | |
callMeFromC(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ForeignFunctionInterface #-} | |
module Main where | |
import qualified Data.ByteString.Char8 as B | |
foreign import ccall "callMeFromHaskell" | |
callMeFromHaskell :: IO () | |
foreign export ccall callMeFromC :: IO () | |
callMeFromC :: IO () | |
callMeFromC = B.putStrLn "callMeFromC" | |
main :: IO () | |
main = do | |
B.putStrLn "main" | |
callMeFromHaskell | |
return () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GHC_OPT := -Wall -O2 -fno-warn-unused-do-bind | |
all: ffiso | |
test: ffiso | |
./$< | |
ffiso: FFISo.hs c.c | |
ghc --make $(GHC_OPT) $^ -o $@ | |
clean: | |
rm -rf *.hi *.o ffiso *_stub.* | |
ghci0: ffiso | |
echo main | ghci FFISo.hs | |
ghci1: ffiso | |
echo main | ghci FFISo.hs c.o | |
ghci2: ffiso | |
echo main | ghci FFISo.hs c.o FFISo.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately only with -fobject-code which also disables debugging.