-
-
Save aavogt/70f55aa85287f0046f3b to your computer and use it in GitHub Desktop.
ghc does not check foreign import types
This file contains 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
double f (double x) { | |
return (x*2); | |
} |
This file contains 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
double f (double x); |
This file contains 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 ForeignFunctionInterface #-} | |
foreign import ccall "a.h f" f :: Int -> Int | |
main = print (f 3) | |
{- | |
ghc a.h a.c main.hs | |
./main | |
130560 | |
prints 6.0 if you give f :: Double -> Double | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment