hsc2hs feature request

Ross Paterson ross@soi.city.ac.uk
Wed, 28 May 2003 13:20:11 +0100


The hsc2hs way of handling header files does not fit well with what is
described by the FFI spec, making it difficult for non-GHC implementations
to use .hsc files.  Typical .hsc files may contain several #include
lines, which turn into OPTIONS -#include pragmas.  The portable way is to
specify the header file in the foreign import, but only one header file
is permitted there.  Now if #def is used, hsc2hs generates a header file
(as well as a C file) that would be suitable for this purpose.  But #def
is deprecated.  So I propose that hsc2hs always generate this header file,
as per the accompanying simple patch.

That leaves the task of adding the header file to all the foreign imports,
which could be done manually or automatically, but at least there would be
a single header file to name.

Index: ghc/utils/hsc2hs/Main.hs
===================================================================
RCS file: /home/cvs/root/fptools/ghc/utils/hsc2hs/Main.hs,v
retrieving revision 1.47
diff -u -r1.47 Main.hs
--- ghc/utils/hsc2hs/Main.hs	20 May 2003 11:07:54 -0000	1.47
+++ ghc/utils/hsc2hs/Main.hs	28 May 2003 12:14:53 -0000
@@ -492,7 +492,7 @@
     let specials = [(pos, key, arg) | Special pos key arg <- toks]
     
     let needsC = any (\(_, key, _) -> key == "def") specials
-        needsH = needsC
+        needsH = True
     
     let includeGuard = map fixChar outHName
             where