As for the errno issues, I think the hsc2hs solution is simple and straightforward and doesn't require an architecture-dependent algebraic datatype. BTW Maloclm, if you haven't yet taken a look at hsc2hs I urge you to do so (fptools/ghc/utils/hsc2hs): it should work unmodified with nhc98, and it'll let you write C constants like EINTR directly in portable Haskell code.
I could imagine such a solution being quite nice. Is there any documentation for hsc2hs? I don't know what its input should look like.
There's some documentation in fptools/ghc/docs/users_guide/utils.sgml (except it's called hs2c there; I didn't get around to updating the name). I can't connect to haskell.org at the moment so I'm not sure if the docs there are up to date enough to have this stuff. Marcin's QForeign library has plenty of examples too. Cheers, Simon
QForeign library has plenty of examples
Ok, I tried hsc2hs on one of the QForeign examples and it gave me the following errors. Any ideas? Regards, Malcolm $ ~/ghc/utils/hsc2hs/Main Glob.hsc -t ~/ghc/utils/hsc2hs/template-hsc.h In file included from /grp/haskell/lib/ghc-4.08/includes/HsFFI.h:17, from ~/ghc/utils/hsc2hs/template-hsc.h:1, from Glob.hsc_make_hs.c:1, /grp/haskell/lib/ghc-4.08/includes/StgTypes.h:45: #error GHC untested on this architecture: sizeof(unsigned int) != 4 /grp/haskell/lib/ghc-4.08/includes/StgTypes.h:65: #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs. /grp/haskell/lib/ghc-4.08/includes/StgTypes.h:82: #error GHC untested on this architecture: sizeof(void *) != 4 or 8 In file included from ~/ghc/utils/hsc2hs/template-hsc.h:1, from Glob.hsc_make_hs.c:1, /grp/haskell/lib/ghc-4.08/includes/HsFFI.h:77: #error GHC untested on this architecture: sizeof(void *) != 4 or 8
Tue, 28 Nov 2000 16:48:11 +0000, malcolm-ffi@cs.york.ac.uk <malcolm-ffi@cs.york.ac.uk> pisze:
Ok, I tried hsc2hs on one of the QForeign examples and it gave me the following errors. Any ideas?
--- /home/users/qrczak/cvs/fptools/ghc/utils/hsc2hs/Main.hs Tue Nov 7 16:28:36 2000 +++ programs/hsc2hs-bin.hs Thu Nov 9 22:38:29 2000 @@ -178,6 +178,9 @@ when needsH $ writeFile outHName $ "#ifndef "++includeGuard++"\n\ \#define "++includeGuard++"\n\ + \#if __GLASGOW_HASKELL__ < 409\n\ + \#include <Rts.h>\n\ + \#endif\n\ \#include <HsFFI.h>\n"++ concatMap outTokenH specials++ "#endif\n" -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
+++ programs/hsc2hs-bin.hs + \#if __GLASGOW_HASKELL__ < 409\n\ + \#include <Rts.h>\n\ + \#endif\n\ Still doesn't work. Ah, but adding the conditional include to template-hsc.h does the job. Glob.hsc, Libgr.hsc, Readline.hsc, and Zlib.hsc all go through the tool fine, but I get errors on some of the other examples: Bzip2.hsc_make_hs.c:279: `BZ_CONFIG_ERROR' undeclared Curses.hsc_make_hs.c:2: ../config.h: No such file or directory Pcap.hsc_make_hs.c:2: pcap.h: No such file or directory Oh, I didn't run ../configure which accounts for the second two, but the Bzip2 still doesn't work. Regards, Malcolm
Wed, 29 Nov 2000 14:02:10 +0000, malcolm-ffi@cs.york.ac.uk <malcolm-ffi@cs.york.ac.uk> pisze:
Bzip2.hsc_make_hs.c:279: `BZ_CONFIG_ERROR' undeclared
I suspect that older versions of bzip2 did not define this constant. I have bzip2-1.0.1. The use of BZ_CONFIG_ERROR in Bzip2.hsc can be protected by #ifdef BZ_CONFIG_ERROR to make it work with other versions.
Curses.hsc_make_hs.c:2: ../config.h: No such file or directory Pcap.hsc_make_hs.c:2: pcap.h: No such file or directory
Oh, I didn't run ../configure which accounts for the second two,
Indeed. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
participants (3)
-
malcolm-ffi@cs.york.ac.uk -
qrczak@knm.org.pl -
Simon Marlow