hsc2hs and #include

Edward Z. Yang ezyang at MIT.EDU
Sat Jul 30 23:23:39 CEST 2011


No, I don't think this diagnosis is correct.  hsc2hs is outputting preprocessor
directives into hs files that GHC will then process.  Inspect your .hs file,
at least for me, I don't see #INCLUDE pragmas output at all, with latest
hsc2hs (old versions just didn't output any ifdefs, so we'd hit the problem.)

Actually, we should check if this problem is actually still around.
Remember you need to use ghc-7.0.3's hsc2hs, not an arbitrary one lying
around (though  it may work).

Cheers,
Edward


Excerpts from Evan Laforge's message of Sat Jul 30 17:10:21 -0400 2011:
> On Sat, Jul 30, 2011 at 8:32 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
> > This is supposed to get defined as a command line argument to the preprocessor,
> > see compiler/main/DriverPipeline.hs.  Are you saying you don't see it when you
> > run hsc2hs? Maybe someone else is calling a preprocessor but missing some of
> > these arguments...
> 
> Yes, I don't see it when I run hsc2hs.  I don't see how a define from
> ghc is going to make it into the hsc2hs generated C file, since it
> just compiles the c file with no special flags.  Looking at the hsc2hs
> source, it runs the c compiler with cFlags, which I think ultimately
> comes from the flags.  Since it doesn't import anything out of ghc I
> don't know how it's supposed to get macros from there either, unless
> that was supposed to have gone into some header.
> 
> Here's my hsc2hs line:
> 
> hsc2hs -v -c g++ --cflag -Wno-invalid-offsetof
> -I/Library/Frameworks/GHC.framework/Versions/7.0.3-x86_64/usr/lib/ghc-7.0.3/include
> \
>         -Ifltk -I. -I/usr/local/src/fltk-dev/fltk-1.3/ -D_THREAD_SAFE
> -D_REENTRANT -DMAC_OS_X_VERSION_MAX_ALLOWED=1060
> -DMAC_OS_X_VERSION_MIN_REQUIRED=1050  Ui/Style.hsc
> Executing: g++ -c Ui/Style_hsc_make.c -o Ui/Style_hsc_make.o
> -Wno-invalid-offsetof
> -I/Library/Frameworks/GHC.framework/Versions/7.0.3-x86_64/usr/lib/ghc-7.0.3/include
> -Ifltk -I. -I/usr/local/src/fltk-dev/fltk-1.3/
> Executing: g++ Ui/Style_hsc_make.o -o Ui/Style_hsc_make
> Executing: Ui/Style_hsc_make  >Ui/Style.hs
> 
> BTW, -Wno-invalid-offsetof was necessary to get the compiler to not
> complain about the C generated by the #poke and #peek macros, and with
> the latest version of hsc2hs I had to explicitly tell it where the ghc
> directory is... I guess it's supposed to get that out of its cabal but
> I'm not sure how.



More information about the Glasgow-haskell-users mailing list