hsc2hs and #include

Evan Laforge qdunkan at gmail.com
Sat Jul 30 21:47:05 CEST 2011

So when I upgrade from 6.10 to 6.12 a LONG time ago, there was a bug
where hsc2hs would emit INCLUDE pragmas and ghc didn't like that.  So
I hacked around it with an extra grep -v step in the Makefile.  I
always meant to go fix it for real in hsc2hs and finally I came back
to that TODO item.  I took a look at the hsc2hs source, and discovered
it's surrounding the INCLUDE line with

#elif __GLASGOW_HASKELL__ < 610

However, that macro is never defined for me, so it always emits the
bogus INCLUDE line.  I can't find anywhere that defines that macro,
but there is a lot of "__GLASGOW_HASKELL && ...".  So I modified
utils/hsc2hs/C.hs from

        "#elif __GLASGOW_HASKELL__ < 610\n"++
        "    printf (\"{-# INCLUDE %s #-}\\n\", \""++
                         showCString s++"\");\n"++


        "#elif __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 610\n"++
        "    printf (\"{-# INCLUDE %s #-}\\n\", \""++
                         showCString s++"\");\n"++

And my problem is solved.  Is this the correct solution?  Where is
that macro defined?

I don't know how to mail patches with git, but anyway it's trivial so
I don't think it's needed :)

More information about the Glasgow-haskell-users mailing list