hsc2hs and #include

Evan Laforge qdunkan at gmail.com
Tue Aug 9 03:44:29 CEST 2011

>> Should I try to send a patch for the remove all backward compatibility
>> thing?  Or one for the specific #include problem I've been having?
> I've lost track of all the details here.  But perhaps there's some
> historical cruft lying around because hsc2hs used to call GHC to compile its
> C files, and hence __GLASGOW_HASKELL__ would have been defined.

Ahh, that could be the explanation.  Perhaps it's been continued just
because someone was making incremental updates and never realized the
original reason the macro worked.

> In fact, the GHC build system passes --cflag=-D__GLASGOW_HASKELL__=<version>
> to hsc2hs when it runs it. Maybe Cabal should do the same.  Does it?

I don't know, but I'm not using cabal.

> The problem with making the INCLUDE pragma conditional is that you can only
> do conditional pragmas using CPP, which requires the CPP extension, and
> moreover older versions of GHC did not support conditional compilation of
> pragmas (I forget which version added this, maybe 6.12).

Right, but unless I'm mistaken, the CPP never goes into haskell, it
goes into the generated C.

So the simplest thing to do is remove all the version stuff.  That
means that if you want to run hsc2hs with a version of ghc which is
not the one linked in /usr/bin, you also can't run the hsc2hs linked
in /usr/bin, but have to get the one out of the ghc directory.  If no
one has an objection to that then I'll try to make a patch with git
and put it in a ticket.

The next simplest thing to do is to just document that anyone calling
hsc2hs has to pass -D__GLASGOW_HASKELL_=version.  I don't like this so
much because it's error-prone, but doesn't require any code changes.
So... remove it all?  Yea / nay?

More information about the Glasgow-haskell-users mailing list