Hi,
you don't say how you processed that example .gc file with GreenCard,
but I'm guessing you used the '--target ghc' option. If that's the case,
have
a look at
http://www.haskell.org/greencard/type-sig.html#SEC-BODY
which discusses safe vs. unsafe calls -- i.e., in your case you need to
change
the %code below to %safecode. (Alternatively, use the -S option).
hth
--sigbjorn
- Original Message -
From: Chen Yu [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, November 22, 2001 03:42
Subject: greencard bug
Hi, there
I am using Greencard with Hask's foreign function export. I found
the following program can cause seg-fault. Anyone has any idea? BTW,
if I replace greencard with Hask's foreign function import, there
is no such error.
in ABC.gc:
foreign export ccall h_add h_add :: Int - IO Int
h_add a = do
putStrLn in haskell callback
return (a + 1)
%fun add :: Int - IO(Int)
%call (int a)
%code int r;
% r = c_add (a);
%result (int r)
and the result is like:
in c callback
in haskell callback
Segmentation Fault
in add.c:
_RESULT c_add(int a) {
printf(in c callback\n);
return h_add(a);
}
TIA!
--
chenyu
in Main.hs:
main = do
a - add 127
putStrLn (show a)
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs