How to access defines and enums in a convenient way?

Martin Norbäck d95mback at dtek.chalmers.se
Fri Jun 6 08:10:00 EDT 2003


fre 2003-06-06 klockan 12.06 skrev Alastair Reid:
> > You want to use a tool to make all this easier.  There are various tools
> > available: green-card, c2hs, and hsc2hs are the most commonly-used ones
> > these days.
> 
> > Alastair Reid wrote a good comparison of the various tools
> > (can't remember the link off hand though).
> 
> It is in:
> 
>   http://www.reid-consulting-uk.ltd.uk/docs/ffi.html
> 
> I've been trying to update it recently so there's some new answers to FAQs but 
> there's also some empty sections where I plan to write something but haven't 
> yet.

hsc2hs solved my problem! It would be even greater if ghc --make could
accept .hsc as source and not generate a .hs file at all, like it does
with .lhs. hsc2hs is distributed with ghc after all.

I actually could persuade ghc to do almost what I want by writing this
little wrapper (hscwrapper):

#!/bin/sh
hsc2hs $2 -o $3

then simply write .chs code directly in the .hs file and calling 
ghc -pgmF hscwrapper -F --make

However, -pgmF is a static option (why is that?) so I can't put it in
the .hs file. This means hsc2hs has to be run for all files and the
compilation goes a bit slower.

Regards,

	Martin

-- 
Martin Norbäck          d95mback at dtek.chalmers.se              
Kapplandsgatan 40       +46 (0)708 26 33 60                    
S-414 78  GÖTEBORG      http://www.dtek.chalmers.se/~d95mback/
SWEDEN                  OpenPGP ID: 3FA8580B




More information about the FFI mailing list