
4 Jun
2003
4 Jun
'03
5:47 a.m.
foreign import ccall "math.h signgam" signgamC :: IO Int
signgam is an "int" variable, but this assumes that it is a function of type "int signgam(void)".
Write a C wrapper "int get_signgam(void) { return signgam; }" and import that.
Or alternatively, foreign import the address of the int and read it directly with 'peek'. import Foreign ... foreign import ccall "math.h &signgam" signgamC :: Ptr Int32 ... gammaIO :: Double -> IO Double gammaIO x = do lg <- lgammaC x s <- peek signgamC return $ fromIntegral s * exp lg Regards, Malcolm